pyhctsa.operations.spectral.bicoherence¶
-
pyhctsa.operations.spectral.bicoherence(y, seg_length=
64, max_n='full')¶ Quadratic phase coupling between frequencies, from the squared bicoherence.
Estimates the bicoherence, a normalized bispectrum, by segment averaging: the series is split into overlapping segments (50% overlap, as many as fit), each segment is demeaned, Hamming-windowed and Fourier transformed, and the per-segment Fourier coefficients are combined into the bispectrum estimate
B(f1,f2) = <X(f1) X(f2) X*(f1+f2)>, averaged over segments. The squared bicoherence isbic2(f1,f2) = |B(f1,f2)|^2 / (<|X(f1)X(f2)|^2> <|X(f1+f2)|^2>)(the normalization of Kim and Powers, 1979), bounded in [0, 1] by the Cauchy-Schwarz inequality.Time-domain nonlinearity statistics (e.g.,
tc3, the ramping-window asymmetry oframping_windows) collapse all frequency structure into a single number per lag, so nonlinear coupling localized to a specific pair of frequency bands can average out to near zero. The bicoherence resolves quadratic phase coupling per frequency pair, directly detecting whether energy at f1 and f2 is phase-coupled to energy at f1+f2 (the frequency-domain signature of a quadratic nonlinearity).The squared bicoherence of a finite segment average is biased upward by an amount set by the number of segments, which grows with the series length. The outputs below are therefore expressed relative to the Gaussian null (see Notes), so that they are near 0 for a linear Gaussian process at any length and approach 1 for perfect coupling.
- Parameters:¶
- y : array-like¶
The input time series.
- seg_length : int, optional¶
The length (in samples) of each FFT segment (at least 16). Segments overlap by 50% and as many as fit are averaged; the number of segments K sets the variance of the bicoherence estimate. Fewer than 8 segments gives NaN. Default is 64.
- max_n : int or 'full', optional¶
The maximum number of samples to consider: longer series are cropped to their first
max_npoints.'full'disables cropping. Default is'full'.
- Returns:¶
meanBic: the mean over the non-redundant principal domain of frequency pairs (0 < f1 <= f2,f1 + f2 <= Nyquist) of the null-corrected squared bicoherence(K_eff * bic2 - 1) / (K_eff - 1).meanBicDiag: the same mean over the self-coupling diagonalf1 = f2(quadratic harmonic distortion).maxBic: the maximum ofbic2over the domain, rescaled as(max - m0) / (1 - m0), withm0the expected maximum under the null.propSig: the proportion of frequency pairs whosebic2exceeds the 95% quantile of the null distribution.entropy: the Shannon entropy of the (uncorrected) bicoherence surface, normalized to [0, 1] by the uniform-distribution entropy: whether coupling is concentrated in a few frequency pairs or diffuse across many.
meanBic,meanBicDiagandmaxBicare 0 in expectation for a linear Gaussian process and 1 for perfect coupling; sampling fluctuation makes individual values slightly negative, and they are not clipped. NaN is returned if the series is too short for 8 segments.- Return type:¶
dict or float
Notes
Null distribution. For a Gaussian process the Fourier coefficient X3 = X(f1+f2) is independent of the product a = X(f1) X(f2) across segments, and is circularly symmetric.
bic2is then the squared cosine between the K-vectors a and X3, which for K independent segments follows a Beta(1, K - 1) distribution whatever a is, with mean 1/K. The uncorrected mean therefore falls like 1/K, that is, like 1/N.Effective segment count. With 50% overlap, neighboring segments are correlated; for white input the Fourier coefficients of segments m steps apart have correlation
r_m = sum_n w[n] w[n + m*step] / sum_n w[n]^2for the window w. The products a then have correlationr_m^2, and the bin phase factors cancel in the triple product, so the null mean ofbic2is 1/K_eff withK_eff = K / (1 + 2 sum_m (1 - m/K) r_m^3)(about K / 1.023 for the Hamming window at 50% overlap), and the null distribution is taken as Beta(1, K_eff - 1).Corrected forms. Each bifrequency is corrected to
bc = (K_eff * bic2 - 1) / (K_eff - 1), which has null mean 0 and equals 1 at perfect coupling. For a summary with null expectation T0 the reported value is(T - T0) / (1 - T0): formaxBicthe maximum of the M non-redundant bifrequencies, withT0 = 1 - B(1 / a, M + 1) / a,a = K_eff - 1and B the beta function (the expected maximum of M independent Beta(1, a) variables); for the means this is the mean ofbc. The threshold ofpropSigis the exact quantile1 - 0.05**(1 / (K_eff - 1))of Beta(1, K_eff - 1). The corrections are first-order: they ignore the small excess of the null mean in the bin next to DC and the O(1/K) bias at strong coupling, and for narrowband (line-spectrum) series, whose Fourier coefficients do not decorrelate between segments, the null level is higher than assumed.