pymks/stats.py
def crosscorrelate(X_, periodic_axes=None, confidence_index=None,
                   crosscorrelations=None):
    """
    Computes the crosscorrelations from a microstructure function.

    Args:
        X_ (ND array): The discretized microstructure function, an
            `(n_samples, n_x, ..., n_states)` shaped array
            where `n_samples` is the number of samples, `n_x` is thes
            patial discretization, and n_states is the number of local states.
        periodic_axes (list, optional): axes that are periodic. (0, 2) would
            indicate that axes x and z are periodic in a 3D microstrucure.
        confidence_index (ND array, optional): array with same shape as X used
            to assign a confidence value for each data point.
        crosscorrelations (list, optional): list of cross-correlatiions to
            be computed. For example [(0, 1), (0, 2)] computes the
            cross-correlations with local states 0 and 1 as well as 0 and 2.
            If no list is passed, all cross-correlations are computed.

    Returns:
        Crosscorelations for microstructure function `X_`.

    Examples

    Test for 2 states.

    >>> n_states = 2
    >>> X = np.array([[[0, 1, 0],
    ...                [0, 1, 0],
    ...                [0, 1, 0]]])
    >>> from pymks.bases import PrimitiveBasis
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> X_cross = crosscorrelate(X_, periodic_axes=[0, 1])
    >>> X_test = np.array([[[[1/3.], [0.], [1/3.]],
    ...                     [[1/3.], [0.], [1/3.]],
    ...                     [[1/3.], [0.], [1/3.]]]])
    >>> assert(np.allclose(X_cross, X_test))

    Test for 3 states

    >>> n_states = 3
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> assert(crosscorrelate(X_, periodic_axes=[0, 1]).shape == (1, 3, 3, 3))

    Test for 4 states

    >>> n_states = 4
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> assert(crosscorrelate(X_, periodic_axes=[0, 1]).shape == (1, 3, 3, 6))

    Test for 5 states

    >>> n_states = 5
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> assert(crosscorrelate(X_, periodic_axes=[0, 1]).shape == (1, 3, 3, 10))
    """
    if periodic_axes is None:
        periodic_axes = []
    if crosscorrelations is None:
        correlations = _cross_correlations(X_.shape[-1])
    X_ = _mask_X_(X_, confidence_index)
    s = _Fkernel_shape(X_, periodic_axes)
    cross = _correlate(X_, s, correlations)
    return cross / _normalize(X_, s, confidence_index)

    Computes the crosscorrelations from a microstructure function.

    Args:
        X_ (ND array): The discretized microstructure function, an
            `(n_samples, n_x, ..., n_states)` shaped array
            where `n_samples` is the number of samples, `n_x` is thes
            patial discretization, and n_states is the number of local states.
        periodic_axes (list, optional): axes that are periodic. (0, 2) would
            indicate that axes x and z are periodic in a 3D microstrucure.
        confidence_index (ND array, optional): array with same shape as X used
            to assign a confidence value for each data point.
        crosscorrelations (list, optional): list of cross-correlatiions to
            be computed. For example [(0, 1), (0, 2)] computes the
            cross-correlations with local states 0 and 1 as well as 0 and 2.
            If no list is passed, all cross-correlations are computed.

    Returns:
        Crosscorelations for microstructure function `X_`.

    Examples

    Test for 2 states.

    >>> n_states = 2
    >>> X = np.array([[[0, 1, 0],
    ...                [0, 1, 0],
    ...                [0, 1, 0]]])
    >>> from pymks.bases import PrimitiveBasis
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> X_cross = crosscorrelate(X_, periodic_axes=[0, 1])
    >>> X_test = np.array([[[[1/3.], [0.], [1/3.]],
    ...                     [[1/3.], [0.], [1/3.]],
    ...                     [[1/3.], [0.], [1/3.]]]])
    >>> assert(np.allclose(X_cross, X_test))

    Test for 3 states

    >>> n_states = 3
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> assert(crosscorrelate(X_, periodic_axes=[0, 1]).shape == (1, 3, 3, 3))

    Test for 4 states

    >>> n_states = 4
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> assert(crosscorrelate(X_, periodic_axes=[0, 1]).shape == (1, 3, 3, 6))

    Test for 5 states

    >>> n_states = 5
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> assert(crosscorrelate(X_, periodic_axes=[0, 1]).shape == (1, 3, 3, 10))
    
Computes the crosscorrelations from a microstructure function.
Computes the crosscorrelations from a microstructure function .
def crosscorrelate(X_, periodic_axes=None, confidence_index=None,
                   crosscorrelations=None):
    if periodic_axes is None:
        periodic_axes = []
    if crosscorrelations is None:
        correlations = _cross_correlations(X_.shape[-1])
    X_ = _mask_X_(X_, confidence_index)
    s = _Fkernel_shape(X_, periodic_axes)
    cross = _correlate(X_, s, correlations)
    return cross / _normalize(X_, s, confidence_index)
def crosscorrelate ( X_ , periodic_axes = None , confidence_index = None , crosscorrelations = None ) : if periodic_axes is None : periodic_axes = [ ] if crosscorrelations is None : correlations = _cross_correlations ( X_ . shape [ - 1 ] ) X_ = _mask_X_ ( X_ , confidence_index ) s = _Fkernel_shape ( X_ , periodic_axes ) cross = _correlate ( X_ , s , correlations ) return cross / _normalize ( X_ , s , confidence_index )
Computes the crosscorrelations from a microstructure function.
Computes the crosscorrelations from a microstructure function .
"""
    Computes the crosscorrelations from a microstructure function.

    Args:
        X_ (ND array): The discretized microstructure function, an
            `(n_samples, n_x, ..., n_states)` shaped array
            where `n_samples` is the number of samples, `n_x` is thes
            patial discretization, and n_states is the number of local states.
        periodic_axes (list, optional): axes that are periodic. (0, 2) would
            indicate that axes x and z are periodic in a 3D microstrucure.
        confidence_index (ND array, optional): array with same shape as X used
            to assign a confidence value for each data point.
        crosscorrelations (list, optional): list of cross-correlatiions to
            be computed. For example [(0, 1), (0, 2)] computes the
            cross-correlations with local states 0 and 1 as well as 0 and 2.
            If no list is passed, all cross-correlations are computed.

    Returns:
        Crosscorelations for microstructure function `X_`.

    Examples

    Test for 2 states.

    >>> n_states = 2
    >>> X = np.array([[[0, 1, 0],
    ...                [0, 1, 0],
    ...                [0, 1, 0]]])
    >>> from pymks.bases import PrimitiveBasis
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> X_cross = crosscorrelate(X_, periodic_axes=[0, 1])
    >>> X_test = np.array([[[[1/3.], [0.], [1/3.]],
    ...                     [[1/3.], [0.], [1/3.]],
    ...                     [[1/3.], [0.], [1/3.]]]])
    >>> assert(np.allclose(X_cross, X_test))

    Test for 3 states

    >>> n_states = 3
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> assert(crosscorrelate(X_, periodic_axes=[0, 1]).shape == (1, 3, 3, 3))

    Test for 4 states

    >>> n_states = 4
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> assert(crosscorrelate(X_, periodic_axes=[0, 1]).shape == (1, 3, 3, 6))

    Test for 5 states

    >>> n_states = 5
    >>> prim_basis = PrimitiveBasis(n_states=n_states)
    >>> X_ = prim_basis.discretize(X)
    >>> assert(crosscorrelate(X_, periodic_axes=[0, 1]).shape == (1, 3, 3, 10))
    """
Crosscorelations for microstructure function `X_`.
Crosscorelations for microstructure function ` X_ ` .
X_
The discretized microstructure function, an
`(n_samples, n_x, ..., n_states)` shaped array
where `n_samples` is the number of samples, `n_x` is thes
patial discretization, and n_states is the number of local states.
The discretized microstructure function an ` ( n_samples n_x ... n_states ) ` shaped array where ` n_samples ` is the number of samples ` n_x ` is thes patial discretization and n_states is the number of local states .
periodic_axes
axes that are periodic. (0, 2) would
indicate that axes x and z are periodic in a 3D microstrucure.
axes that are periodic . ( 0 2 ) would indicate that axes x and z are periodic in a 3D microstrucure .
confidence_index
array with same shape as X used
to assign a confidence value for each data point.
array with same shape as X used to assign a confidence value for each data point .
crosscorrelations
list of cross-correlatiions to
be computed. For example [(0, 1), (0, 2)] computes the
cross-correlations with local states 0 and 1 as well as 0 and 2.
If no list is passed, all cross-correlations are computed.
list of cross - correlatiions to be computed . For example [ ( 0 1 ) ( 0 2 ) ] computes the cross - correlations with local states 0 and 1 as well as 0 and 2 . If no list is passed all cross - correlations are computed .