# Namespace Features¶

namespace features

Functions

af::array absEnergy(af::array base)

Calculates the absolute energy of the time series which is the sum over the squared values.

$E = \sum_{i=1,\ldots, n} x_i^2$
.

Return
af::array An array with the same dimensions as tss, whose values (time series in dimension 0) contains the sum of the squares values in the time series.
Parameters
• base: 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.

af::array absoluteSumOfChanges(af::array tss)

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

$\sum_{i=1, \ldots, n-1} \mid x_{i+1}- x_i \mid$
.

Return
af::array An array with the same dimensions as tss, whose values (time series in dimension 0) contains absolute value of consecutive changes in the time series.
Parameters
• tss: 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.

af::array aggregatedAutocorrelation(af::array tss, af::array (*aggregationFunction)(const af::array&, const bool, const dim_t))

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).

$\frac{1}{n-1} \sum_{l=1,\ldots, n} \frac{1}{(n-l)\sigma^{2}} \sum_{t=1}^{n-l}(X_{t}-\mu )(X_{t+l}-\mu),$
where $$n$$ is the length of the time series $$X_i$$, $$\sigma^2$$ its variance and $$\mu$$ its mean.

Return
af::array An array with the same dimensions as tss, whose values (time series in dimension 0) contains the aggregated correlation for each time series.
Parameters
• tss: 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: The function to summarise all autocorrelation with different lags.

af::array aggregatedAutocorrelation(af::array tss, af::array (*aggregationFunction)(const af::array&, const int))

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).

$\frac{1}{n-1} \sum_{l=1,\ldots, n} \frac{1}{(n-l)\sigma^{2}} \sum_{t=1}^{n-l}(X_{t}-\mu )(X_{t+l}-\mu),$
where $$n$$ is the length of the time series $$X_i$$, $$\sigma^2$$ its variance and $$\mu$$ its mean.

Return
af::array An array with the same dimensions as tss, whose values (time series in dimension 0) contains the aggregated correlation for each time series.
Parameters
• tss: 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: The function to summarise all autocorrelation with different lags.

af::array aggregatedAutocorrelation(af::array tss, af::array (*aggregationFunction)(const af::array&, const dim_t))

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).

$\frac{1}{n-1} \sum_{l=1,\ldots, n} \frac{1}{(n-l)\sigma^{2}} \sum_{t=1}^{n-l}(X_{t}-\mu )(X_{t+l}-\mu),$
where $$n$$ is the length of the time series $$X_i$$, $$\sigma^2$$ its variance and $$\mu$$ its mean.

Return
af::array An array with the same dimensions as tss, whose values (time series in dimension 0) contains the aggregated correlation for each time series.
Parameters
• tss: 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: The function to summarise all autocorrelation with different lags.

void aggregatedLinearTrend(af::array t, long chunkSize, af::array (*aggregationFunction)(const af::array&, const int), af::array &slope, af::array &intercept, af::array &rvalue, af::array &pvalue, af::array &stderrest, )

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
• t: The time series to calculate the features of.
• chunkSize: The chunkSize used to aggregate the data.
• aggregationFunction: Function to be used in the aggregation.
• slope: Slope of the regression line.
• intercept: Intercept of the regression line.
• rvalue: Correlation coefficient.
• pvalue: 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.
• stderrest: Standard error of the estimated gradient.

void aggregatedLinearTrend(af::array t, long chunkSize, af::array (*aggregationFunction)(const af::array&, const dim_t), af::array &slope, af::array &intercept, af::array &rvalue, af::array &pvalue, af::array &stderrest, )

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
• t: The time series to calculate the features of.
• chunkSize: The chunkSize used to aggregate the data.
• aggregationFunction: Function to be used in the aggregation.
• slope: Slope of the regression line.
• intercept: Intercept of the regression line.
• rvalue: Correlation coefficient.
• pvalue: 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.
• stderrest: Standard error of the estimated gradient.

af::array approximateEntropy(af::array tss, 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., The Appropriate Use of Approximate Entropy and Sample Entropy with Short Data Sets, (2012). Other shortcomings and alternatives discussed in: Richman & Moorman, Physiological time-series analysis using approximate entropy and sample entropy, (2000).

Return
af::array An array with the same dimensions as tss, whose values (time series in dimension 0) contains the vectorized Approximate entropy for all the input time series in tss.
Parameters
• tss: 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.

af::array autoCorrelation(af::array tss, long maxLag, bool unbiased = false)

Calculates the autocorrelation of the specified lag for the given time series, according to the formula .

$\frac{1}{(n-l)\sigma^{2}} \sum_{t=1}^{n-l}(X_{t}-\mu )(X_{t+l}-\mu),$
where $$n$$ is the length of the time series $$X_i$$, $$\sigma^2$$ its variance and $$\mu$$ its mean, $$l$$ denotes the lag.

Return
af::array The autocorrelation value for the given time series.
Parameters
• tss: 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).

af::array autoCovariance(af::array xss, bool unbiased = false)

Calculates the auto-covariance the given time series.

Return
af::array The auto-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.
• unbiased: Determines whether it divides by n - lag (if true) or n (if false).

af::array binnedEntropy(af::array tss, int max_bins)

Calculates the binned entropy for the given time series and number of bins. It calculates the value of:

$\sum_{k=0}^{min(max\_bins, len(x))} p_k log(p_k) \cdot \mathbf{1}_{(p_k > 0)},$
where $$p_k$$ is the percentage of samples in bin $$k$$.

Return
af::array The binned entropy value for the given time series.
Parameters
• tss: 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.
• max_bins: The number of bins.

af::array c3(af::array tss, long 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} \cdot x_{i},$
which is:
$\mathbb{E}[L^2(X)^2 \cdot L(X) \cdot X],$
where $$\mathbb{E}$$ is the mean and $$L$$ is the lag operator. It was proposed in  as a measure of non linearity in the time series.

 Schreiber, T. and Schmitz, A., Discrimination power of measures for nonlinearity in a time series, PHYSICAL REVIEW E, VOLUME 55, NUMBER 5, (1997).

Return
af::array The non-linearity value for the given time series.
Parameters
• tss: 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.

af::array cidCe(af::array tss, bool zNormalize = false)

This function calculator is an estimate for a time series complexity 1. It calculates the value of:

$\sqrt{ \sum_{i=0}^{n-2lag} ( x_{i} - x_{i+1})^2 }.$
.

 Batista, Gustavo EAPA, et al (2014). CID: an efficient complexity-invariant distance for time series. Data Mining and Knowledge Difscovery 28.3 (2014): 634-669.

Return
af::array The complexity value for the given time series.
Parameters
• tss: 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.

af::array countAboveMean(af::array tss)

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

Return
af::array The number of values in the time series that are higher than the mean.
Parameters
• tss: 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.

af::array countBelowMean(af::array tss)

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

Return
af::array The number of values in the time series that are lower than the mean.
Parameters
• tss: 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.

af::array crossCovariance(af::array xss, af::array yss, bool unbiased = true)

Calculates the cross-covariance of the given time series.

Return
af::array 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).

af::array crossCorrelation(af::array xss, af::array yss, bool unbiased = true)

Calculates the cross-correlation of the given time series.

Return
af::array 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: Determines whether it divides by n - lag (if true) or n (if false).

af::array cwtCoefficients(af::array tss, af::array widths, int coeff, int w)

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

$\frac{2}{\sqrt{3a} \pi^{ \frac{1} { 4 }}} (1 - \frac{x^2}{a^2}) exp(-\frac{x^2}{2a^2}),$
where $$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.

Return
af::array Result of calculated coefficients.
Parameters
• tss: 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.
• widths: Array that contains all different widths.
• coeff: Coefficient of interest.
• w: Width of interest.

af::array energyRatioByChunks(af::array tss, 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. segmentFocus should be lower than the number of segments.

Return
af::array The energy ratio by chunk of the time series.
Parameters
• tss: 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.

af::array fftAggregated(af::array tss)

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

Return
af::array The spectral centroid (mean), variance, skew, and kurtosis of the absolute fourier transform spectrum.
Parameters
• tss: 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.

void fftCoefficient(af::array tss, long coefficient, af::array &real, af::array &imag, af::array &abs, af::array &angle)

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

$A_k = \sum_{m=0}^{n-1} a_m \exp \left \{ -2 \pi i \frac{m k}{n} \right \}, \qquad k = 0, \ldots , n-1.$
.

Parameters
• tss: 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.
• real: The real part of the coefficient.
• imag: The imaginary part of the coefficient.
• abs: The absolute value of the coefficient.
• angle: The angle of the coefficient.

af::array firstLocationOfMaximum(af::array tss)

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

Return
af::array The first relative location of the maximum value to the length of the time series, for each time series.
Parameters
• tss: 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.

af::array firstLocationOfMinimum(af::array tss)

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

Return
af::array the first relative location of the minimal value of each time series.
Parameters
• tss: 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.

af::array friedrichCoefficients(af::array tss, 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 . For short time series this method is highly dependent on the parameters.

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

Return
af::array The coefficients for each time series.
Parameters
• tss: 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.

af::array hasDuplicates(af::array tss)

Computes if the input time series contain duplicated elements.

Return
af::array Array containing True if the time series contains duplicated elements and false otherwise.
Parameters
• tss: 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.

af::array hasDuplicateMax(af::array tss)

Computes if the maximum within time series is duplicated.

Return
af::array Array containing True if the maximum value of the time series is duplicated and false otherwise.
Parameters
• tss: 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.

af::array hasDuplicateMin(af::array tss)

Computes if the minimum of input time series is duplicated.

Return
af::array Array containing True if the minimum of the time series is duplicated and false otherwise.
Parameters
• tss: 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.

af::array indexMassQuantile(af::array tss, float q)

Calculates the relative index $$i$$ where $$q\%$$ of the mass of the time series within tss lie at the left of $$i$$. For example for $$q = 50\%$$ this feature calculator will return the mass center of the time series.

Return
af::array The relative indices i where q% of the mass of the time series lie at the left of i.
Parameters
• tss: 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 limit.

af::array kurtosis(af::array tss)

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

Return
af::array The kurtosis of tss.
Parameters
• tss: 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.

af::array largeStandardDeviation(af::array tss, float r)

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

$std(x) > r * (max(X)-min(X)).$
.

Return
af::array Array containing True for those time series in tss that have a large standard deviation.
Parameters
• tss: 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 value.

af::array lastLocationOfMaximum(af::array tss)

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

Return
af::array The last relative location of the maximum value of each time series.
Parameters
• tss: 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.

af::array lastLocationOfMinimum(af::array tss)

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

Return
af::array The last relative location of the minimum value of each series.
Parameters
• tss: 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.

af::array length(af::array tss)

Returns the length of the input time series.

Return
af::array The length of tss.
Parameters
• tss: 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.

void linearTrend(af::array tss, af::array &pvalue, af::array &rvalue, af::array &intercept, af::array &slope, af::array &stder)

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.

Parameters
• tss: 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.
• pvalue: The p-values for all time series.
• rvalue: The r-values for all time series.
• intercept: The intercept values for all time series.
• slope: The slope for all time series.
• stder: The stderr values for all time series.

af::array localMaximals(af::array tss)

Calculates all Local Maximals for the time series in tss.

Return
af::array The calculated local maximals for each time series in tss.
Parameters
• tss: 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.

af::array longestStrikeAboveMean(af::array tss)

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

Return
af::array the length of the longest consecutive subsequence in the input time series that is bigger than the mean.
Parameters
• tss: 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.

af::array longestStrikeBelowMean(af::array tss)

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

Return
af::array The length of the longest consecutive subsequence in the input time series that is below the mean.
Parameters
• tss: 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.

af::array maxLangevinFixedPoint(af::array tss, 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)$
.

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

Return
af::array Largest fixed point of deterministic dynamics.
Parameters
• tss: 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. NOTE: the time series should be sorted.
• m: Order of polynom to fit for estimating fixed points of dynamics.
• r: Number of quantiles to use for averaging.

af::array maximum(af::array tss)

Calculates the maximum value for each time series within tss.

Return
af::array The maximum value of each time series within tss.
Parameters
• tss: 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.

af::array mean(af::array tss)

Calculates the mean value for each time series within tss.

Return
af::array The mean value of each time series within tss.
Parameters
• tss: 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.

af::array meanAbsoluteChange(af::array tss)

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

$\frac{1}{n} \sum_{i=1,\ldots, n-1} | x_{i+1} - x_{i}|.$
.

Return
af::array The mean over the absolute differences between subsequent time series values.
Parameters
• tss: 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.

af::array meanChange(af::array tss)

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

$\frac{1}{n} \sum_{i=1,\ldots, n-1} x_{i+1} - x_{i}.$
.

Return
af::array The mean over the differences between subsequent time series values.
Parameters
• tss: 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.

af::array meanSecondDerivativeCentral(af::array tss)

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

$\frac{1}{n} \sum_{i=1,\ldots, n-1} \frac{1}{2} (x_{i+2} - 2 \cdot x_{i+1} + x_i).$
.

Return
af::array The mean value of a central approximation of the second derivative for each time series.
Parameters
• tss: 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.

af::array median(af::array tss)

Calculates the median value for each time series within tss.

Return
af::array The median value of each time series within tss.
Parameters
• tss: 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.

af::array minimum(af::array tss)

Calculates the minimum value for each time series within tss.

Return
af::array The minimum value of each time series within tss.
Parameters
• tss: 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.

af::array numberCrossingM(af::array tss, 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
af::array The number of m-crossings of each time series within tss.
Parameters
• tss: 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.

af::array numberCwtPeaks(af::array tss, 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 maxW. This feature calculator returns the number of peaks that occur at enough width scales and with sufficiently high Signal-to-Noise-Ratio (SNR).

Return
af::array The number of peaks for each time series.
Parameters
• tss: 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.

af::array numberPeaks(af::array tss, int n)

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

 Bioinformatics (2006) 22 (17): 2059-2065. doi: 10.1093/bioinformatics/btl355, http://bioinformatics.oxfordjournals.org/content/22/17/2059.long

Return
af::array The number of peaks of at least support $$n$$.
Parameters
• tss: 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.

af::array partialAutocorrelation(af::array tss, af::array 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$$ (). Following , 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  that, for an AR(p), the partial autocorrelations $$\alpha_k$$ will be nonzero for $$k<=p$$ and zero for $$k>p$$. With this property, it is used to determine the lag of an AR-Process.

 Box, G. E., Jenkins, G. M., Reinsel, G. C., & Ljung, G. M. (2015). Time series analysis: forecasting and control. John Wiley & Sons.

Return
af::array The partial autocorrelation for each time series for the given lag.
Parameters
• tss: 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.

af::array percentageOfReoccurringDatapointsToAllDatapoints(af::array tss, bool isSorted = false)

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

$\frac{len(\textit{different values occurring more than once})}{len(\textit{different values})}$
This means the percentage is normalized to the number of unique values, in contrast to the percentageOfReoccurringValuesToAllValues.

Return
af::array The percentage of unique data points, that are present in the time series more than once.
Parameters
• tss: 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.

af::array percentageOfReoccurringValuesToAllValues(af::array tss, 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
af::array The percentage of unique values, that are present in the time series more than once.
Parameters
• tss: 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.

af::array quantile(af::array tss, af::array q, float precision = 100000000)

Returns values at the given quantile.

Return
af::array Values at the given quantile.
Parameters
• tss: 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.

af::array rangeCount(af::array tss, float min, float max)

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

Return
af::array Values at the given range.
Parameters
• tss: 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.

af::array ratioBeyondRSigma(af::array tss, float r)

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

Return
af::array The ratio of values that are more than $$r*std(x)$$ (so $$r$$ sigma) away from the mean of $$x$$.
Parameters
• tss: 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.

af::array ratioValueNumberToTimeSeriesLength(af::array tss)

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
af::array The ratio of unique values with respect to the total number of values.
Parameters
• tss: 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.

af::array sampleEntropy(af::array tss)

Calculates a vectorized sample entropy algorithm. For short time-series this method is highly dependent on the parameters, but should be stable for N > 2000, see:

 Yentes et al., The Appropriate Use of Approximate Entropy and Sample Entropy with Short Data Sets, (2012).

 Richman & Moorman,Physiological time-series analysis using approximate entropy and sample entropy, (2000).

Return
af::array With the same dimensions as tss, whose values (time series in dimension 0) contains the vectorized sample entropy for all the input time series in tss.
Parameters
• tss: 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.

af::array skewness(af::array tss)

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

Return
af::array Containing the skewness of each time series in tss.
Parameters
• tss: 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.

af::array spktWelchDensity(af::array tss, int coeff)

Estimates the cross power spectral density of the time series tss 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.

 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.

 M.S. Bartlett, “Periodogram Analysis and Continuous Spectra”, Biometrika, vol. 37, pp. 1-16, 1950.

 Rabiner, Lawrence R., and B. Gold. “Theory and Application of Digital Signal Processing” Prentice-Hall, pp. 414-419, 1975.

Return
af::array Containing the power spectrum of the different frequencies for each time series in tss.
Parameters
• tss: 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.

af::array standardDeviation(af::array tss)

Calculates the standard deviation of each time series within tss.

Return
af::array The standard deviation of each time series within tss.
Parameters
• tss: 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.

af::array sumOfReoccurringDatapoints(af::array tss, bool isSorted = false)

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

Return
af::array The sum of all data points, that are present in the time series more than once.
Parameters
• tss: 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.

af::array sumOfReoccurringValues(af::array tss, bool isSorted = false)

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

Return
af::array Returns the sum of all values, that are present in the time series more than once.
Parameters
• tss: 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.

af::array sumValues(af::array tss)

Calculates the sum over the time series tss.

Return
af::array An array containing the sum of values in each time series.
Parameters
• tss: 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.

af::array symmetryLooking(af::array tss, float r)

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

$| mean(tss)-median(tss)| < r * (max(tss)-min(tss)).$
.

Return
af::array Denoting if the input time series look symmetric.
Parameters
• tss: 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.

af::array timeReversalAsymmetryStatistic(af::array tss, 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  as a promising feature to extract from time series.

 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
af::array Containing the time reversal asymmetry statistic value in each time series.
Parameters
• tss: 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 to be computed.

af::array valueCount(af::array tss, float v)

Counts occurrences of value in the time series tss.

Return
af::array Containing the count of the given value in each time series.
Parameters
• tss: 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.

af::array variance(af::array tss)

Computes the variance for the time series tss.

Return
af::array An array containing the variance in each time series.
Parameters
• tss: 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.

af::array varianceLargerThanStandardDeviation(af::array tss)

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

Return
af::array Denoting if the variance of tss is greater than the standard deviation.
Parameters
• tss: 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.