ntrfc.timeseries package¶
Submodules¶
ntrfc.timeseries.integral_scales module¶
- ntrfc.timeseries.integral_scales.get_self_correlating_frequencies(timesteps, signal)¶
Calculate the self-correlating frequencies in a signal.
- Parameters:
timesteps (ndarray) – An array of uniformly spaced timesteps, corresponding to the time intervals between samples in the signal.
signal (ndarray) – The input signal to analyze.
- Returns:
frequencies – An array of self-correlating frequencies, in units of inverse timesteps.
- Return type:
ndarray
Notes
This function calculates the autocorrelation of the input signal, and finds the local maxima in the autocorrelation signal. These local maxima correspond to the self-correlating frequencies in the signal.
- ntrfc.timeseries.integral_scales.integralscales(signal, timesteparray)¶
ntrfc.timeseries.stationarity module¶
- ntrfc.timeseries.stationarity.estimate_error_jacknife(timeseries, block_size=20, n_samples=4000)¶
Estimates the errors of the mean, variance, and autocorrelation of a given time series using jackknife resampling method.
- Parameters:
timeseries (array-like) – The input time series.
block_size (int, optional) – The block size used in the jackknife resampling method (default is 20).
n_samples (int, optional) – The number of jackknife samples to generate (default is 4000).
- Returns:
A tuple of three floats representing the error estimates of the mean, variance, and autocorrelation, respectively.
- Return type:
tuple
Notes
- The jackknife resampling method is used to estimate the errors of the mean, variance, and autocorrelation of the
input time series.
- The function generates n_samples jackknife samples by randomly selecting blocks from the time series calculates
the mean, variance, and autocorrelation of each jackknife sample.
- It also generates n_samples noise samples with the same block size as the original time series and calculates the
mean, variance, and autocorrelation of each noise sample.
- The standard deviation of the jackknife estimates for mean, variance, and autocorrelation are calculated, and each
is multiplied by a factor of 16 to obtain the final error estimates.
- Choosing an appropriate block size is crucial for obtaining reliable and accurate estimates of the errors of the
mean, variance, and autocorrelation of a given time series using the jackknife resampling method.
- ntrfc.timeseries.stationarity.estimate_stationarity(timeseries, verbose=False)¶
- ntrfc.timeseries.stationarity.optimal_bin_width(sample1, sample2)¶
Compute the optimal bin width using cross-validation estimator for mean integrated squared error.
Parameters:¶
- datanumpy array
One-dimensional array of data points.
Returns:¶
- hfloat
Optimal bin width.
- ntrfc.timeseries.stationarity.optimal_window_size(time_series, min_interval=0.05, max_interval=0.25, verbose=False)¶
Determines the optimal window size for a given time series.
Parameters:¶
- time_seriesarray-like
The time series to analyze.
- verbosebool, optional
If True, a plot of the correlation coefficient and KS test results for each window size will be displayed.
Returns:¶
- int or bool
The optimal window size for the time series. If no suitable window size is found, False is returned.
Notes:¶
The function normalizes the input time series using the minmax_normalize() function. The window size is chosen based on a cumulative score that takes into account the correlation coefficient and
KS test p-value.
- The function returns False if no suitable window size is found, meaning the input time series does not exhibit the
necessary periodicity.
- ntrfc.timeseries.stationarity.smd_probability_compare(sample1, sample2, verbose=False)¶
Compare the probability distribution of two signals using the Freedman-Diaconis rule to determine the number of bins.
- Parameters:
sample1 (numpy.ndarray) – First signal.
sample2 (numpy.ndarray) – Second signal.
- Returns:
- Mean squared error between the probability distribution densities
of the two signals. A value of 0 indicates that the probability distributions are not alike, while a value of 1 indicates that they are equal.
- Return type:
float