def _temporal_derivative(data, params, report):
    """
    Performs mtd method. See func: teneto.derive.derive.
    """
    # Data should be timexnode
    report = {}

    # Derivative
    tdat = data[1:, :] - data[:-1, :]
    # Normalize
    tdat = tdat / np.std(tdat, axis=0)
    # Coupling
    coupling = np.array([tdat[:, i] * tdat[:, j] for i in np.arange(0,
                                                                    tdat.shape[1]) for j in np.arange(0, tdat.shape[1])])
    coupling = np.reshape(
        coupling, [tdat.shape[1], tdat.shape[1], tdat.shape[0]])
    # Average over window using strides
    shape = coupling.shape[:-1] + (coupling.shape[-1] -
                                   params['windowsize'] + 1, params['windowsize'])
    strides = coupling.strides + (coupling.strides[-1],)
    coupling_windowed = np.mean(np.lib.stride_tricks.as_strided(
        coupling, shape=shape, strides=strides), -1)

    report = {}
    report['method'] = 'temporalderivative'
    report['temporalderivative'] = {}
    report['temporalderivative']['windowsize'] = params['windowsize']

    return coupling_windowed, report
def _temporal_derivative ( data , params , report ) : report = { } tdat = data [ 1 : , : ] - data [ : - 1 , : ] tdat = tdat / np . std ( tdat , axis = 0 ) coupling = np . array ( [ tdat [ : , i ] * tdat [ : , j ] for i in np . arange ( 0 , tdat . shape [ 1 ] ) for j in np . arange ( 0 , tdat . shape [ 1 ] ) ] ) coupling = np . reshape ( coupling , [ tdat . shape [ 1 ] , tdat . shape [ 1 ] , tdat . shape [ 0 ] ] ) shape = coupling . shape [ : - 1 ] + ( coupling . shape [ - 1 ] - params [ 'windowsize' ] + 1 , params [ 'windowsize' ] ) strides = coupling . strides + ( coupling . strides [ - 1 ] , ) coupling_windowed = np . mean ( np . lib . stride_tricks . as_strided ( coupling , shape = shape , strides = strides ) , - 1 ) report = { } report [ 'method' ] = 'temporalderivative' report [ 'temporalderivative' ] = { } report [ 'temporalderivative' ] [ 'windowsize' ] = params [ 'windowsize' ] return coupling_windowed , report
Performs mtd method. See func: teneto.derive.derive.