1.5. Namespace Features

class Features

Khiva Features class containing a number of features that can be extracted from time series. All the methods operate with instances of the ARRAY class as input and output.

Public Static Functions

static KhivaArray Khiva.Features.AbsEnergy(KhivaArray array)

Calculates the sum over the square values of the time series.

Return
An array with the same dimensions as array, whose values (time series in dimension 0) contains the sum of the squares values in the time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.AbsoluteSumOfChanges(KhivaArray array)

Calculates the sum over the absolute value of consecutive changes in the time series.

Return
An array with the same dimensions as array, whose values (time series in dimension 0) contains absolute value of consecutive changes in the time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.AggregatedAutoCorrelation(KhivaArray array, int aggregationFunction)

Calculates the value of an aggregation function f_agg (e.g. var or mean) of the autocorrelation (Compare to http://en.wikipedia.org/wiki/Autocorrelation#Estimation), taken over different all possible lags(1 to length of x).

Return
An array whose values contains the aggregated correlation for each time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • aggregationFunction: Function to be used in the aggregation.It receives an integer which indicates the function to be applied: { 0 : mean, 1 : median 2 : min, 3 : max, 4 : stdev, 5 : var, default : mean }

static Tuple<KhivaArray, KhivaArray, KhivaArray, KhivaArray, KhivaArray> Khiva.Features.AggregatedLinearTrend(KhivaArray array, long chunkSize, int aggregationFunction)

Calculates a linear least-squares regression for values of the time series that were aggregated over chunks versus the sequence from 0 up to the number of chunks minus one.

Parameters
  • array: The time series to calculate the features of
  • chunkSize: The chunk size used to aggregate the data.
  • aggregationFunction: Function to be used in the aggregation. It receives an integer which indicates the function to be applied: { 0 : mean, 1 : median 2 : min, 3 : max, 4 : stdev, default : mean } /param>
    Return
    Tuple with the slope of the regression line, the intercept of the regression line, the correlation coefficient, the two-sided p-value for a hypothesis test whose null hypothesis is that the slope is zero, using Wald Test with t-distribution of the test statistic and the standard error of the estimated gradient.

static KhivaArray Khiva.Features.ApproximateEntropy(KhivaArray array, int m, float r)

Calculates a vectorized Approximate entropy algorithm. https://en.wikipedia.org/wiki/Approximate_entropy For short time-series this method is highly dependent on the parameters, but should be stable for N > 2000, see: Yentes et al. (2012) - The Appropriate Use of Approximate Entropy and Sample Entropy with Short Data Sets Other shortcomings and alternatives discussed in: Richman &; Moorman (2000) - Physiological time-series analysis using approximate entropy and sample entropy.

Return
The vectorized approximate entropy for all the input time series in array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • m: Length of compared run of data.
  • r: Filtering level, must be positive.

static KhivaArray Khiva.Features.CrossCovariance(KhivaArray xss, KhivaArray yss, bool unbiased)

Calculates the cross-covariance of the given time series.

Return
The cross-covariance value for the given time series.
Parameters
  • xss: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • yss: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • unbiased: Determines whether it divides by n - lag (if true) or n(if false).

static KhivaArray Khiva.Features.AutoCovariance(KhivaArray array, bool unbiased = false)

Calculates the auto-covariance the given time series.

Return
The auto-covariance value for the given time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • unbiased: Determines whether it divides by n - lag (if true) or n(if false).

static KhivaArray Khiva.Features.CrossCorrelation(KhivaArray xss, KhivaArray yss, bool unbiased)

Calculates the cross-correlation of the given time series.

Return
The cross-correlation value for the given time series.
Parameters
  • xss: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

  • yss: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

  • unbiased

static KhivaArray Khiva.Features.AutoCorrelation(KhivaArray array, long maxLag, bool unbiased)

Calculates the autocorrelation of the specified lag for the given time series.

Return
The autocorrelation value for the given time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • maxLag: The maximum lag to compute.
  • unbiased: Determines whether it divides by n - lag (if true) or n ( if false)

static KhivaArray Khiva.Features.BinnedEntropy(KhivaArray array, int maxBins)

Calculates the binned entropy for the given time series and number of bins.

Return
The binned entropy value for the given time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • maxBins: The number of bins.

static KhivaArray Khiva.Features.C3(KhivaArray array, long lag)

Calculates the Schreiber, T. and Schmitz, A. (1997) measure of non-linearity for the given time series.

Return
The non-linearity value for the given time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • lag: The lag.

static KhivaArray Khiva.Features.CidCe(KhivaArray array, bool zNormalize)

Calculates an estimate for the time series complexity defined by Batista, Gustavo EAPA, et al(2014). (A more complex time series has more peaks, valleys, etc.).

Return
The complexity value for the given time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • zNormalize: Controls whether the time series should be z-normalized or not.

static KhivaArray Khiva.Features.CountAboveMean(KhivaArray array)

Calculates the number of values in the time series that are higher than the mean.

Return
The number of values in the time series that are higher than the mean.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.CountBelowMean(KhivaArray array)

Calculates the number of values in the time series that are lower than the mean.

Return
The number of values in the time series that are lower than the mean.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.CwtCoefficients(KhivaArray array, KhivaArray width, int coeff, int w)

Calculates a Continuous wavelet transform for the Ricker wavelet, also known as the “Mexican hat wavelet” which is defined by:

.. math:: {2}{{3a} ^{ {1} { 4 }}} (1 - {x^2}{a^2}) exp(-{ x ^ 2}{2a^2})

where :math:a is the width parameter of the wavelet function.

This feature calculator takes three different parameter: widths, coeff and w.The feature calculator takes all the different widths arrays and then calculates the cwt one time for each different width array.Then the values for the different coefficient for coeff and width w are returned. (For each dic in param one feature is returned).

Return
Result of calculated coefficients.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.
  • width: KhivaArray that contains all different widths.
  • coeff: Coefficient of interest.
  • w: Width of interest.

static KhivaArray Khiva.Features.EnergyRatioByChunks(KhivaArray array, long numSegments, long segmentFocus)

Calculates the sum of squares of chunk i out of N chunks expressed as a ratio with the sum of squares over the whole series. segment_focus should be lower than the number of segments.

Return
The energy ratio by chunk of the time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • numSegments: The number of segments to divide the series into.
  • segmentFocus: The segment number (starting at zero) to return a feature on.

static KhivaArray Khiva.Features.FftAggregated(KhivaArray array)

Calculates the spectral centroid(mean), variance, skew, and kurtosis of the absolute fourier transform spectrum.

Return
The spectral centroid (mean), variance, skew, and kurtosis of the absolute fourier transform spectrum.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static Tuple<KhivaArray, KhivaArray, KhivaArray, KhivaArray> Khiva.Features.FftCoefficient(KhivaArray array, long coefficient)

Calculates the fourier coefficients of the one-dimensional discrete Fourier Transform for real input by fast fourier transformation algorithm.

Return
Tuple with the real part of the coefficient, the imaginary part of the coefficient, the absolute value of the coefficient and the angle of the coefficient.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • coefficient: The coefficient to extract from the FFT.

static KhivaArray Khiva.Features.FirstLocationOfMaximum(KhivaArray array)

Calculates the first relative location of the maximal value for each time series.

Return
The first relative location of the maximum value to the length of the time series, for each time series.
Parameters
  • array: array Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.FirstLocationOfMinimum(KhivaArray array)

Calculates the first location of the minimal value of each time series. The position is calculated relatively to the length of the series.

Return
The first relative location of the minimal value of each series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.FriedrichCoefficients(KhivaArray array, int m, float r)

Coefficients of polynomial \(h(x)\), which has been fitted to the deterministic dynamics of Langevin model:

\[ \dot(x)(t) = h(x(t)) + R \mathcal(N)(0,1) \]
as described by[1]. For short time series this method is highly dependent on the parameters.

[1] Friedrich et al. (2000): Physics Letters A 271, p. 217-222 Extracting model equations from experimental data.

Return
The coefficients for each time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.
  • m: Order of polynom to fit for estimating fixed points of dynamics.
  • r: Number of quantiles to use for averaging.

static KhivaArray Khiva.Features.HasDuplicates(KhivaArray array)

Calculates if the input time series contain duplicated elements.

Return
KhivaArray containing True if the time series contains duplicated elements and false otherwise.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.HasDuplicateMax(KhivaArray array)

Calculates if the maximum within input time series is duplicated.

Return
KhivaArray containing True if the maximum value of the time series is duplicated and false otherwise.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.HasDuplicateMin(KhivaArray array)

Calculates if the minimum of the input time series is duplicated.

Return
KhivaArray containing True if the minimum of the time series is duplicated and false otherwise.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.IndexMassQuantile(KhivaArray array, float q)

Calculates the index of the max quantile.

Return
The index of the max quantile q.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • q: The quantile.

static KhivaArray Khiva.Features.Kurtosis(KhivaArray array)

Returns the kurtosis of array (calculated with the adjusted Fisher-Pearson standardized moment coefficient G2).

Return
The kurtosis of each array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.LargeStandardDeviation(KhivaArray array, float r)

Checks if the time series within array have a large standard deviation.

Return
KhivaArray containing True for those time series in array that have a large standard deviation.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • r: The threshold.

static KhivaArray Khiva.Features.LastLocationOfMaximum(KhivaArray array)

Calculates the last location of the maximum value of each time series. The position is calculated relatively to the length of the series.

Return
The last relative location of the maximum value of each series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.LastLocationOfMinimum(KhivaArray array)

Calculates the last location of the minimum value of each time series. The position is calculated relatively to the length of the series.

Return
The last relative location of the minimum value of each series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.Length(KhivaArray array)

Returns the length of the input time series.

Return
The length of the time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static Tuple<KhivaArray, KhivaArray, KhivaArray, KhivaArray, KhivaArray> Khiva.Features.LinearTrend(KhivaArray array)

Calculate a linear least-squares regression for the values of the time series versus the sequence from 0 to length of the time series minus one.

Return
Tuple with the pvalues for all time series, the rvalues for all time series, the intercept values for all time series, the slope for all time series and the stderr values for all time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.LocalMaximals(KhivaArray array)

Calculates all Local Maximals fot the time series in array.

Return
The calculated local maximals for each time series in array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.LongestStrikeAboveMean(KhivaArray array)

Calculates the length of the longest consecutive subsequence in array that is bigger than the mean of array.

Return
The length of the longest consecutive subsequence in the input time series that is bigger than the mean.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.LongestStrikeBelowMean(KhivaArray array)

Calculates the length of the longest consecutive subsequence in array that is below the mean of array.

Return
The length of the longest consecutive subsequence in the input time series that is below the mean.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.MaxLangevinFixedPoint(KhivaArray array, int m, float r)

Largest fixed point of dynamics \(\max_x {h(x)=0}\) estimated from polynomial \(h(x)\), which has been fitted to the deterministic dynamics of Langevin model

\[ \dot(x)(t) = h(x(t)) + R \mathcal(N)(0, 1) \]
as described by Friedrich et al. (2000): Physics Letters A 271, p. 217-222 *Extracting model equations from experimental data.

Return
Largest fixed point of deterministic dynamics.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • m: Order of polynom to fit for estimating fixed points of dynamics.
  • r: Number of quantiles to use for averaging.

static KhivaArray Khiva.Features.Maximum(KhivaArray array)

Calculates the maximum value for each time series within array.

Return
The maximum value of each time series within array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.Mean(KhivaArray array)

Calculates the mean value for each time series within array.

Return
The mean value of each time series within array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.MeanAbsoluteChange(KhivaArray array)

Calculates the mean over the absolute differences between subsequent time series values in array.

Return
The maximum value of each time series within array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.MeanChange(KhivaArray array)

Calculates the mean over the differences between subsequent time series values in array.

Return
The mean over the differences between subsequent time series values.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.MeanSecondDerivativeCentral(KhivaArray array)

Calculates mean value of a central approximation of the second derivative for each time series in array.

Return
The mean value of a central approximation of the second derivative for each time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.Median(KhivaArray array)

Calculates the median value for each time series within array.

Return
The median value of each time series within array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.Minimum(KhivaArray array)

Calculates the minimum value for each time series within array.

Return
The minimum value of each time series within array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.NumberCrossingM(KhivaArray array, int m)

Calculates the number of m-crossings. A m-crossing is defined as two sequential values where the first value is lower than m and the next is greater, or viceversa.If you set m to zero, you will get the number of zero crossings.

Return
The number of m-crossings of each time series within array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • m: The m value.

static KhivaArray Khiva.Features.NumberCwtPeaks(KhivaArray array, int maxW)

This feature calculator searches for different peaks. To do so, the time series is smoothed by a ricker wavelet and for widths ranging from 1 to max_w.This feature calculator returns the number of peaks that occur at enough width scales and with sufficiently high Signal-to-Noise-Ratio (SNR).

Return
The number of peaks for each time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.
  • maxW: The maximum width to consider.

static KhivaArray Khiva.Features.NumberPeaks(KhivaArray array, int n)

Calculates the number of peaks of at least support \(n\) in the time series \(array\). A peak of support \(n\) is defined as a subsequence of \(array\) where a value occurs, which is bigger than its \(n\) neighbours to the left and to the right.

Return
The number of peaks of at least support \(n\).
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • n: The support of the peak.

static KhivaArray Khiva.Features.PartialAutocorrelation(KhivaArray array, KhivaArray lags)

Calculates the value of the partial autocorrelation function at the given lag. The lag \(k\) partial autocorrelation of a time series \(\lbrace x_t, t = 1 \ldots T \rbrace\) equals the partial correlation of \(x_t\) and \(x_{t-k}\), adjusted for the intermediate variables \(\lbrace x_ { t-1}, \ldots, x_{t-k+1} \rbrace\) ([1]). Following[2], it can be defined as:

\[ \alpha_k = \frac{ Cov(x_t, x_{ t - k} | x_{t-1}, \ldots, x_{t-k+1})} {\sqrt{ Var(x_t | x_{ t - 1}, \ldots, x_{t-k+1}) Var(x_{ t - k} | x_{t-1}, \ldots, x_{t-k+1} )}} \]
with(a) \(x_t = f(x_{ t - 1}, \ldots, x_{t-k+1})\) and(b) \( x_{t-k} = f(x_{ t - 1}, \ldots, x_{t-k+1})\) being AR(k-1) models that can be fitted by OLS.Be aware that in (a), the regression is done on past values to predict \( x_t \) whereas in (b), future values are used to calculate the past value \(x_{t-k}\)

. It is said in [1] that “for an AR(p), the partial autocorrelations \form#21 will be nonzero for \form#22

and zero for \form#23.” With this property, it is used to determine the lag of an AR-Process.

[1] Box, G.E., Jenkins, G.M., Reinsel, G.C., & Ljung, G.M. (2015). Time series analysis: forecasting and control. John Wiley & Sons. [2] https://onlinecourses.science.psu.edu/stat510/node/62

Return
Returns partial autocorrelation for each time series for the given lag.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.
  • lags: Indicates the lags to be calculated.

static KhivaArray Khiva.Features.PercentageOfReoccurringDatapointsToAllDatapoints(KhivaArray array, bool isSorted = false)

Calculates the percentage of unique values, that are present in the time series more than once.

\[ len(different values occurring more than once) / len(different values) \]
This means the percentage is normalized to the number of unique values, in contrast to the percentageOfReoccurringValuesToAllValues.

Return
Returns the percentage of unique values, that are present in the time series more than once.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • isSorted: Indicates if the input time series is sorted or not. Defaults to false.

static KhivaArray Khiva.Features.PercentageOfReoccurringValuesToAllValues(KhivaArray array, bool isSorted = false)

Calculates the percentage of unique values, that are present in the time series more than once.

\[ \frac{\textit{number of data points occurring more than once}}{\textit{number of all data points})} \]
This means the percentage is normalized to the number of unique values, in contrast to the percentageOfReoccurringDatapointsToAllDatapoints.

Return
Returns the percentage of unique values, that are present in the time series more than once.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.
  • isSorted: Indicates if the input time series is sorted or not. Defaults to false.

static KhivaArray Khiva.Features.Quantile(KhivaArray array, KhivaArray q, float precision = 1e8F)

Returns values at the given quantile.

Return
Values at the given quantile.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • q: Percentile(s) at which to extract score(s). One or many.
  • precision: Number of decimals expected. Defaults to 1e8F.

static KhivaArray Khiva.Features.RangeCount(KhivaArray array, float min, float max)

Counts observed values within the interval [min, max).

Return
Values at the given range.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • min: Value that sets the lower limit.
  • max: Value that sets the upper limit.

static KhivaArray Khiva.Features.RatioBeyondRSigma(KhivaArray array, float r)

Calculates the ratio of values that are more than \(r*std(x)\) (so \(r\) sigma) away from the mean of \(x\).

Return
The ratio of values that are more than \(r*std(x)\) (so \(r\) sigma) away from the mean of \(x\).
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • r: Number of times that the values should be away from.

static KhivaArray Khiva.Features.RatioValueNumberToTimeSeriesLength(KhivaArray array)

Calculates a factor which is 1 if all values in the time series occur only once, and below one if this is not the case. In principle, it just returns:

\[ \frac{\textit{number\_unique\_values}}{\textit{number\_values}} \]

Return
The ratio of unique values with respect to the total number of values.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.SampleEntropy(KhivaArray array)

Calculates a vectorized sample entropy algorithm. https://en.wikipedia.org/wiki/Sample_entropy https://www.ncbi.nlm.nih.gov/pubmed/10843903?dopt=Abstract For short time-series this method is highly dependent on the parameters, but should be stable for N > 2000, see: Yentes et al. (2012) - The Appropriate Use of Approximate Entropy and Sample Entropy with Short Data Sets Other shortcomings and alternatives discussed in: Richman & Moorman (2000) - Physiological time-series analysis using approximate entropy and sample entropy.

Return
An array with the same dimensions as array, whose values (time series in dimension 0) contains the vectorized sample entropy for all the input time series in array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.Skewness(KhivaArray array)

Calculates the sample skewness of array (calculated with the adjusted Fisher-Pearson standardized moment coefficient G1).

Return
KhivaArray containing the skewness of each time series in array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.SpktWelchDensity(KhivaArray array, int coeff)

Estimates the cross power spectral density of the time series array at different frequencies. To do so, the time series is first shifted from the time domain to the frequency domain.

Welch’s method computes an estimate of the power spectral density by dividing the data into overlapping segments, computing a modified periodogram for each segment and averaging the periodograms. [1] P.Welch, “The use of the fast Fourier transform for the estimation of power spectra: A method based on time

averaging over short, modified periodograms”, IEEE Trans. Audio Electroacoust. vol. 15, pp. 70-73, 1967. [2] M.S.Bartlett, “Periodogram Analysis and Continuous Spectra”, Biometrika, vol. 37, pp. 1-16, 1950. [3] Rabiner, Lawrence R., and B. Gold. “Theory and Application of Digital Signal Processing” Prentice-Hall, pp. 414-419, 1975.

Return
KhivaArray containing the power spectrum of the different frequencies for each time series in array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.
  • coeff: The coefficient to be returned.

static KhivaArray Khiva.Features.StandardDeviation(KhivaArray array)

Calculates the standard deviation of each time series within array.

Return
The standard deviation of each time series within array.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.SumOfReoccurringDatapoints(KhivaArray array, bool isSorted = false)

Calculates the sum of all data points, that are present in the time series more than once.

Return
Returns the sum of all data points, that are present in the time series more than once.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • isSorted: Indicates if the input time series is sorted or not. Defaults to false.

static KhivaArray Khiva.Features.SumOfReoccurringValues(KhivaArray array, bool isSorted = false)

Calculates the sum of all values, that are present in the time series more than once.

Return
Returns the sum of all values, that are present in the time series more than once.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.
  • isSorted: Indicates if the input time series is sorted or not. Defaults to false.

static KhivaArray Khiva.Features.SumValues(KhivaArray array)

Calculates the sum over the time series array.

Return
An array containing the sum of values in each time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.SymmetryLooking(KhivaArray array, float r)

Calculates if the distribution of array looks symmetric. This is the case if

\[ | mean(array) - median(array) | \lt r * (max(array) - min(array)) \]

Return
An array denoting if the input time series look symmetric.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • r: The percentage of the range to compare with.

static KhivaArray Khiva.Features.TimeReversalAsymmetryStatistic(KhivaArray array, int lag)

This function calculates the value of:

\[ \frac{1}{n-2lag} \sum_{i=0}^{n-2lag} x_{i + 2 \cdot lag}^2 \cdot x_ { i + lag } - x_{i + lag} \cdot x_ { i }^2 \]
which is
\[ \mathbb{E}[L^2(X)^2 \cdot L(X) - L(X) \cdot X^2] \]
where \( \mathbb{E} \) is the mean and \( L \) is the lag operator. It was proposed in [1] as a promising feature to extract from time series.

[1] Fulcher, B.D., Jones, N.S. (2014). Highly comparative feature-based time-series classification. Knowledge and Data Engineering, IEEE Transactions on 26, 3026–3037.

Return
An array containing the time reversal asymmetry statistic value in each time series.
Parameters
  • array: xpects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.
  • lag: The lag to be computed.

static KhivaArray Khiva.Features.ValueCount(KhivaArray array, float v)

Counts occurrences of value in the time series array.

Return
An array containing the count of the given value in each time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series(all the same) and dimension one indicates the number of time series.
  • v: The value to be counted.

static KhivaArray Khiva.Features.Variance(KhivaArray array)

Computes the variance for the time series array.

Return
An array containing the variance in each time series.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.

static KhivaArray Khiva.Features.VarianceLargerThanStandardDeviation(KhivaArray array)

Calculates if the variance of array is greater than the standard deviation. In other words, if the variance of array is larger than 1.

Return
An array denoting if the variance of array is greater than the standard deviation.
Parameters
  • array: Expects an input array whose dimension zero is the length of the time series (all the same) and dimension one indicates the number of time series.