sine_f_test

sine_f_test(window_fun: ~numpy.ndarray, x_p: ~numpy.ndarray) -> (<class 'numpy.ndarray'>, <class 'numpy.ndarray'>)[source][source]

Computes the F-statistic for sine wave in locally-white noise.

This function computes the F-statistic for a sine wave in locally-white noise. The sine wave is assumed to be of the form:

\(x(t) = A \sin(2 \pi f t + \phi)\)

where \(A\) is the amplitude of the sine wave, \(f\) is the frequency of the sine wave, and \(\phi\) is the phase of the sine wave. The F-statistic is computed by taking the ratio of the variance of the sine wave to the variance of the noise. The variance of the sine wave is computed by taking the sum of the squares of the sine wave across tapers and then dividing by the number of tapers. The variance of the noise is computed by taking the sum of the squares of the residuals across tapers and then dividing by the number of tapers minus one. The F-statistic is then computed by taking the ratio of the variance of the sine wave to the variance of the noise.

Parameters:
  • window_fun (array) – The tapers used to calculate the multitaper spectrum.

  • x_p (array) – The tapered time series.

Returns:

  • f_stat (array) – The F-statistic for each frequency.

  • A (array) – The amplitude of the sine wave at each frequency.

  • Examples

  • ---------

  • >>> import numpy as np

  • >>> window_fun = np.array([[0.5, 0.5], [0.5, -0.5]])

  • >>> x_p = np.array([[[1, 1, 1, 1, 1], [0, 60, 0, 10, 0]],

  •                  [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]]).T

  • >>> sine_f_test(window_fun, x_p)

  • (array([[0. , 0.        ], – [0.00027778, 0. ], [0. , 0. ], [0.01 , 0. ], [0. , 0. ]]), array([[1., 1.], [1., 1.], [1., 1.], [1., 1.], [1., 1.]]))

Return type:

(<class ‘numpy.ndarray’>, <class ‘numpy.ndarray’>)