neurokit2/complexity/fractal_dfa.py
def _slopes(windows, fluctuations, q, lim=[None, None]):
    """
    Extra the slopes of each `q` power obtained with MFDFA to later produce
    either the singularity spectrum or the multifractal exponents.

    Notes
    -----
    This was first designed and implemented by Leonardo Rydin in
    `MFDFA <https://github.com/LRydin/MFDFA/>`_ and ported here by the same.

    """

    # if no limits given
    if lim[0] is None and lim[1] is None:
        lim = [windows[1], windows[windows.size // 2]]

    # clean q
    q = _cleanse_q(q)

    # Fractal powers as floats
    q = np.asarray_chkfinite(q, dtype=float)

    # Ensure mfdfa has the same q-power entries as q
    if fluctuations.shape[1] != q.shape[0]:
        raise ValueError(
            "Fluctuation function and q powers don't match in dimension.")

    # Allocated array for slopes
    dfa = np.zeros(len(q))

    # Find slopes of each q-power
    for i in range(len(q)):
        dfa[i] = np.polyfit(np.log2(windows), np.log2(fluctuations[:, i]), 1)[0]

    return dfa

    Extra the slopes of each `q` power obtained with MFDFA to later produce
    either the singularity spectrum or the multifractal exponents.

    Notes
    -----
    This was first designed and implemented by Leonardo Rydin in
    `MFDFA <https://github.com/LRydin/MFDFA/>`_ and ported here by the same.

    
Extra the slopes of each `q` power obtained with MFDFA to later produce
either the singularity spectrum or the multifractal exponents.

Notes

This was first designed and implemented by Leonardo Rydin in
`MFDFA `_ and ported here by the same.
Extra the slopes of each ` q ` power obtained with MFDFA to later produce either the singularity spectrum or the multifractal exponents . Notes This was first designed and implemented by Leonardo Rydin in ` MFDFA ` _ and ported here by the same .
def _slopes(windows, fluctuations, q, lim=[None, None]):
    if lim[0] is None and lim[1] is None:
        lim = [windows[1], windows[windows.size // 2]]
    q = _cleanse_q(q)
    q = np.asarray_chkfinite(q, dtype=float)
    if fluctuations.shape[1] != q.shape[0]:
        raise ValueError(
            "Fluctuation function and q powers don't match in dimension.")
    dfa = np.zeros(len(q))
    for i in range(len(q)):
        dfa[i] = np.polyfit(np.log2(windows), np.log2(fluctuations[:, i]), 1)[0]
    return dfa
def _slopes ( windows , fluctuations , q , lim = [ None , None ] ) : if lim [ 0 ] is None and lim [ 1 ] is None : lim = [ windows [ 1 ] , windows [ windows . size // 2 ] ] q = _cleanse_q ( q ) q = np . asarray_chkfinite ( q , dtype = float ) if fluctuations . shape [ 1 ] != q . shape [ 0 ] : raise ValueError ( "Fluctuation function and q powers don't match in dimension." ) dfa = np . zeros ( len ( q ) ) for i in range ( len ( q ) ) : dfa [ i ] = np . polyfit ( np . log2 ( windows ) , np . log2 ( fluctuations [ : , i ] ) , 1 ) [ 0 ] return dfa
Extra the slopes of each `q` power obtained with MFDFA to later produce
either the singularity spectrum or the multifractal exponents.
Extra the slopes of each ` q ` power obtained with MFDFA to later produce either the singularity spectrum or the multifractal exponents .
"""
    Extra the slopes of each `q` power obtained with MFDFA to later produce
    either the singularity spectrum or the multifractal exponents.

    Notes
    -----
    This was first designed and implemented by Leonardo Rydin in
    `MFDFA <https://github.com/LRydin/MFDFA/>`_ and ported here by the same.

    """ # if no limits given # clean q # Fractal powers as floats # Ensure mfdfa has the same q-power entries as q # Allocated array for slopes # Find slopes of each q-power
windows
fluctuations
q
lim