pymks/stats.py
def correlate(X_, periodic_axes=None,
              confidence_index=None, correlations=None):
    """
    Computes the autocorrelations and 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.
        correlations (list, optional): list of  spatial correlatiions to
            be computed. For example [(0, 0), (1, 1), (0, 2)] computes the
            autocorrelations with local states 0 and 1 as well as the
            cross-correlation between 0 and 2. If no list is passed, all
            spatial correlations are computed.

    Returns:
        Autocorrelations and crosscorrelations for microstructure funciton
        `X_`.

    Example

    >>> from pymks import PrimitiveBasis
    >>> prim_basis = PrimitiveBasis(2, [0, 1])
    >>>
    >>> np.random.seed(0)
    >>> X = np.random.randint(2, size=(1, 3))
    >>> X_ = prim_basis.discretize(X)
    >>> X_corr = correlate(X_)
    >>> X_result = np.array([[0, 0.5, 0],
    ...                      [1 / 3., 2 / 3., 0],
    ...                      [0, 0.5, 0.5]])
    >>> assert np.allclose(X_corr, X_result)
    """
    if periodic_axes is None:
        periodic_axes = []
    if correlations is None:
        L = X_.shape[-1]
        correlations = _auto_correlations(L) + _cross_correlations(L)
    X_ = _mask_X_(X_, confidence_index)
    s = _Fkernel_shape(X_, periodic_axes)
    corr = _correlate(X_, s, correlations)
    return corr / _normalize(X_, s, confidence_index)

    Computes the autocorrelations and 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.
        correlations (list, optional): list of  spatial correlatiions to
            be computed. For example [(0, 0), (1, 1), (0, 2)] computes the
            autocorrelations with local states 0 and 1 as well as the
            cross-correlation between 0 and 2. If no list is passed, all
            spatial correlations are computed.

    Returns:
        Autocorrelations and crosscorrelations for microstructure funciton
        `X_`.

    Example

    >>> from pymks import PrimitiveBasis
    >>> prim_basis = PrimitiveBasis(2, [0, 1])
    >>>
    >>> np.random.seed(0)
    >>> X = np.random.randint(2, size=(1, 3))
    >>> X_ = prim_basis.discretize(X)
    >>> X_corr = correlate(X_)
    >>> X_result = np.array([[0, 0.5, 0],
    ...                      [1 / 3., 2 / 3., 0],
    ...                      [0, 0.5, 0.5]])
    >>> assert np.allclose(X_corr, X_result)
    
Computes the autocorrelations and crosscorrelations from a microstructure
function.
Computes the autocorrelations and crosscorrelations from a microstructure function .
def correlate(X_, periodic_axes=None,
              confidence_index=None, correlations=None):
    if periodic_axes is None:
        periodic_axes = []
    if correlations is None:
        L = X_.shape[-1]
        correlations = _auto_correlations(L) + _cross_correlations(L)
    X_ = _mask_X_(X_, confidence_index)
    s = _Fkernel_shape(X_, periodic_axes)
    corr = _correlate(X_, s, correlations)
    return corr / _normalize(X_, s, confidence_index)
def correlate ( X_ , periodic_axes = None , confidence_index = None , correlations = None ) : if periodic_axes is None : periodic_axes = [ ] if correlations is None : L = X_ . shape [ - 1 ] correlations = _auto_correlations ( L ) + _cross_correlations ( L ) X_ = _mask_X_ ( X_ , confidence_index ) s = _Fkernel_shape ( X_ , periodic_axes ) corr = _correlate ( X_ , s , correlations ) return corr / _normalize ( X_ , s , confidence_index )
Computes the autocorrelations and crosscorrelations from a microstructure
function.
Computes the autocorrelations and crosscorrelations from a microstructure function .
"""
    Computes the autocorrelations and 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.
        correlations (list, optional): list of  spatial correlatiions to
            be computed. For example [(0, 0), (1, 1), (0, 2)] computes the
            autocorrelations with local states 0 and 1 as well as the
            cross-correlation between 0 and 2. If no list is passed, all
            spatial correlations are computed.

    Returns:
        Autocorrelations and crosscorrelations for microstructure funciton
        `X_`.

    Example

    >>> from pymks import PrimitiveBasis
    >>> prim_basis = PrimitiveBasis(2, [0, 1])
    >>>
    >>> np.random.seed(0)
    >>> X = np.random.randint(2, size=(1, 3))
    >>> X_ = prim_basis.discretize(X)
    >>> X_corr = correlate(X_)
    >>> X_result = np.array([[0, 0.5, 0],
    ...                      [1 / 3., 2 / 3., 0],
    ...                      [0, 0.5, 0.5]])
    >>> assert np.allclose(X_corr, X_result)
    """
Autocorrelations and crosscorrelations for microstructure funciton
`X_`.
Autocorrelations and crosscorrelations for microstructure funciton ` 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 .
correlations
list of  spatial correlatiions to
be computed. For example [(0, 0), (1, 1), (0, 2)] computes the
autocorrelations with local states 0 and 1 as well as the
cross-correlation between 0 and 2. If no list is passed, all
spatial correlations are computed.
list of spatial correlatiions to be computed . For example [ ( 0 0 ) ( 1 1 ) ( 0 2 ) ] computes the autocorrelations with local states 0 and 1 as well as the cross - correlation between 0 and 2 . If no list is passed all spatial correlations are computed .