Repository: chlubba/catch22 Branch: main Commit: d39af485c9fe Files: 142 Total size: 385.6 KB Directory structure: gitextract_0hyl0dq4/ ├── .github/ │ └── workflows/ │ └── github-repo-stats.yml ├── .gitignore ├── C/ │ ├── .gitignore │ ├── CO_AutoCorr.c │ ├── CO_AutoCorr.h │ ├── DN_HistogramMode_10.c │ ├── DN_HistogramMode_10.h │ ├── DN_HistogramMode_5.c │ ├── DN_HistogramMode_5.h │ ├── DN_Mean.c │ ├── DN_Mean.h │ ├── DN_OutlierInclude.c │ ├── DN_OutlierInclude.h │ ├── DN_Spread_Std.c │ ├── DN_Spread_Std.h │ ├── FC_LocalSimple.c │ ├── FC_LocalSimple.h │ ├── IN_AutoMutualInfoStats.c │ ├── IN_AutoMutualInfoStats.h │ ├── MD_hrv.c │ ├── MD_hrv.h │ ├── PD_PeriodicityWang.c │ ├── PD_PeriodicityWang.h │ ├── SB_BinaryStats.c │ ├── SB_BinaryStats.h │ ├── SB_CoarseGrain.c │ ├── SB_CoarseGrain.h │ ├── SB_MotifThree.c │ ├── SB_MotifThree.h │ ├── SB_TransitionMatrix.c │ ├── SB_TransitionMatrix.h │ ├── SC_FluctAnal.c │ ├── SC_FluctAnal.h │ ├── SP_Summaries.c │ ├── SP_Summaries.h │ ├── butterworth.c │ ├── butterworth.h │ ├── fft.c │ ├── fft.h │ ├── helper_functions.c │ ├── helper_functions.h │ ├── histcounts.c │ ├── histcounts.h │ ├── main.c │ ├── main.h │ ├── runAllTS.sh │ ├── splinefit.c │ ├── splinefit.h │ ├── stats.c │ └── stats.h ├── LICENSE ├── Matlab/ │ ├── BasisOperations/ │ │ ├── BF_Binarize.m │ │ ├── CO_AutoCorr.m │ │ ├── CO_FirstZero.m │ │ ├── CO_trev.m │ │ ├── DN_HistogramMode.m │ │ ├── DN_OutlierInclude_001_mdrmd.m │ │ ├── NK_hist2.m │ │ ├── SB_CoarseGrain_quantile.m │ │ ├── SB_TransitionMatrix.m │ │ ├── SC_FluctAnal_q2_taustep50_k1_logi_prop_r1.m │ │ ├── SP_Summaries_welch_rect.m │ │ ├── buffer_.m │ │ ├── decimate_.m │ │ ├── downsample_.m │ │ ├── filtfilt_.m │ │ ├── histcounts_.m │ │ ├── myButter.m │ │ ├── poly_.m │ │ ├── splinefit.m │ │ ├── test_zp2ss.m │ │ ├── testfilt.m │ │ └── welchy.m │ ├── CO_Embed2_Dist_tau_d_expfit_meandiff.m │ ├── CO_FirstMin_ac.m │ ├── CO_HistogramAMI_even_2_5.m │ ├── CO_f1ecac.m │ ├── CO_trev_1_num.m │ ├── DN_HistogramMode_10.m │ ├── DN_HistogramMode_5.m │ ├── DN_Mean.m │ ├── DN_OutlierInclude_n_001_mdrmd.m │ ├── DN_OutlierInclude_p_001_mdrmd.m │ ├── DN_Spread_Std.m │ ├── FC_LocalSimple_mean1_tauresrat.m │ ├── FC_LocalSimple_mean3_stderr.m │ ├── IN_AutoMutualInfoStats_40_gaussian_fmmi.m │ ├── MD_hrv_classic_pnn40.m │ ├── PD_PeriodicityWang_th0_01.m │ ├── SB_BinaryStats_diff_longstretch0.m │ ├── SB_BinaryStats_mean_longstretch1.m │ ├── SB_MotifThree_quantile_hh.m │ ├── SB_TransitionMatrix_3ac_sumdiagcov.m │ ├── SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1.m │ ├── SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1.m │ ├── SP_Summaries_welch_rect_area_5_1.m │ └── SP_Summaries_welch_rect_centroid.m ├── README.md ├── catch22.m ├── featureList.txt ├── testData/ │ ├── runtests.sh │ ├── test.txt │ ├── test2.txt │ ├── test2_output.txt │ ├── testInf.txt │ ├── testInfMinus.txt │ ├── testNaN.txt │ ├── testShort.txt │ ├── testShort_output.txt │ ├── testSinusoid.txt │ ├── testSinusoid_output.txt │ └── test_output.txt └── wrap_Matlab/ ├── GetAllFeatureNames.m ├── M_wrapper.c ├── M_wrapper.h ├── catch22_CO_Embed2_Dist_tau_d_expfit_meandiff.c ├── catch22_CO_FirstMin_ac.c ├── catch22_CO_HistogramAMI_even_2_5.c ├── catch22_CO_f1ecac.c ├── catch22_CO_trev_1_num.c ├── catch22_DN_HistogramMode_10.c ├── catch22_DN_HistogramMode_5.c ├── catch22_DN_Mean.c ├── catch22_DN_OutlierInclude_n_001_mdrmd.c ├── catch22_DN_OutlierInclude_p_001_mdrmd.c ├── catch22_DN_Spread_Std.c ├── catch22_FC_LocalSimple_mean1_tauresrat.c ├── catch22_FC_LocalSimple_mean3_stderr.c ├── catch22_IN_AutoMutualInfoStats_40_gaussian_fmmi.c ├── catch22_MD_hrv_classic_pnn40.c ├── catch22_PD_PeriodicityWang_th0_01.c ├── catch22_SB_BinaryStats_diff_longstretch0.c ├── catch22_SB_BinaryStats_mean_longstretch1.c ├── catch22_SB_MotifThree_quantile_hh.c ├── catch22_SB_TransitionMatrix_3ac_sumdiagcov.c ├── catch22_SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1.c ├── catch22_SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1.c ├── catch22_SP_Summaries_welch_rect_area_5_1.c ├── catch22_SP_Summaries_welch_rect_centroid.c ├── catch22_all.m ├── mexAll.m └── testing.m ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/github-repo-stats.yml ================================================ name: github-repo-stats on: schedule: # Run this once per day, towards the end of the day for keeping the most # recent data point most meaningful (hours are interpreted in UTC). - cron: "0 23 * * *" workflow_dispatch: # Allow for running this manually. jobs: j1: name: github-repo-stats runs-on: ubuntu-latest steps: - name: run-ghrs # Use latest release. uses: jgehrcke/github-repo-stats@RELEASE with: ghtoken: ${{ secrets.ghrs_github_api_token }} ================================================ FILE: .gitignore ================================================ *.prj *.mexmaci64 *.mexmaca64 *.mat *.m~ .DS_Store *.vscode *.code-workspace */run_features ================================================ FILE: C/.gitignore ================================================ codegen *.prj *.mexmaci64 *.o C_polished generated header timeSeries* featureOutputs ================================================ FILE: C/CO_AutoCorr.c ================================================ #if __cplusplus # include typedef std::complex< double > cplx; #else # include #if defined(__GNUC__) || defined(__GNUG__) typedef double complex cplx; #elif defined(_MSC_VER) typedef _Dcomplex cplx; #endif #endif #include #include #include #include #include "stats.h" #include "fft.h" #include "histcounts.h" #include "helper_functions.h" #ifndef CMPLX #define CMPLX(x, y) ((cplx)((double)(x) + _Imaginary_I * (double)(y))) #endif #define pow2(x) (1 << x) int nextpow2(int n) { n--; n |= n >> 1; n |= n >> 2; n |= n >> 4; n |= n >> 8; n |= n >> 16; n++; return n; } /* static void apply_conj(cplx a[], int size, int normalize) { switch(normalize) { case(1): for (int i = 0; i < size; i++) { a[i] = conj(a[i]) / size; } break; default: for (int i = 0; i < size; i++) { a[i] = conj(a[i]); } break; } } */ void dot_multiply(cplx a[], cplx b[], int size) { for (int i = 0; i < size; i++) { a[i] = _Cmulcc(a[i], conj(b[i])); } } double * CO_AutoCorr(const double y[], const int size, const int tau[], const int tau_size) { double m, nFFT; m = mean(y, size); nFFT = nextpow2(size) << 1; cplx * F = malloc(nFFT * sizeof *F); cplx * tw = malloc(nFFT * sizeof *tw); for (int i = 0; i < size; i++) { #if defined(__GNUC__) || defined(__GNUG__) F[i] = CMPLX(y[i] - m, 0.0); #elif defined(_MSC_VER) cplx tmp = { y[i] - m, 0.0 }; F[i] = tmp; #endif } for (int i = size; i < nFFT; i++) { #if defined(__GNUC__) || defined(__GNUG__) F[i] = CMPLX(0.0, 0.0); #elif defined(_MSC_VER) cplx tmp = { 0.0, 0.0 }; F[i] = tmp; // CMPLX(0.0, 0.0); #endif } // size = nFFT; twiddles(tw, nFFT); fft(F, nFFT, tw); dot_multiply(F, F, nFFT); fft(F, nFFT, tw); cplx divisor = F[0]; for (int i = 0; i < nFFT; i++) { //F[i] = F[i] / divisor; F[i] = _Cdivcc(F[i], divisor); } double * out = malloc(tau_size * sizeof(out)); for (int i = 0; i < tau_size; i++) { out[i] = creal(F[tau[i]]); } free(F); free(tw); return out; } double * co_autocorrs(const double y[], const int size) { double m, nFFT; m = mean(y, size); nFFT = nextpow2(size) << 1; cplx * F = malloc(nFFT * 2 * sizeof *F); cplx * tw = malloc(nFFT * 2 * sizeof *tw); for (int i = 0; i < size; i++) { #if defined(__GNUC__) || defined(__GNUG__) F[i] = CMPLX(y[i] - m, 0.0); #elif defined(_MSC_VER) cplx tmp = { y[i] - m, 0.0 }; F[i] = tmp; #endif } for (int i = size; i < nFFT; i++) { #if defined(__GNUC__) || defined(__GNUG__) F[i] = CMPLX(0.0, 0.0); #elif defined(_MSC_VER) cplx tmp = { 0.0, 0.0 }; F[i] = tmp; #endif } //size = nFFT; twiddles(tw, nFFT); fft(F, nFFT, tw); dot_multiply(F, F, nFFT); fft(F, nFFT, tw); cplx divisor = F[0]; for (int i = 0; i < nFFT; i++) { F[i] = _Cdivcc(F[i], divisor); // F[i] / divisor; } double * out = malloc(nFFT * 2 * sizeof(out)); for (int i = 0; i < nFFT; i++) { out[i] = creal(F[i]); } free(F); free(tw); return out; } int co_firstzero(const double y[], const int size, const int maxtau) { //double * autocorrs = malloc(size * sizeof * autocorrs); //autocorrs = co_autocorrs(y, size); double * autocorrs = co_autocorrs(y, size); int zerocrossind = 0; while(autocorrs[zerocrossind] > 0 && zerocrossind < maxtau) { zerocrossind += 1; } free(autocorrs); return zerocrossind; } double CO_f1ecac(const double y[], const int size) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return 0; } } // compute autocorrelations double * autocorrs = co_autocorrs(y, size); // threshold to cross double thresh = 1.0/exp(1); double out = (double)size; for(int i = 0; i < size-2; i++){ // printf("i=%d autocorrs_i=%1.3f\n", i, autocorrs[i]); if ( autocorrs[i+1] < thresh ){ double m = autocorrs[i+1] - autocorrs[i]; double dy = thresh - autocorrs[i]; double dx = dy/m; out = ((double)i) + dx; // printf("thresh=%1.3f AC(i)=%1.3f AC(i-1)=%1.3f m=%1.3f dy=%1.3f dx=%1.3f out=%1.3f\n", thresh, autocorrs[i], autocorrs[i-1], m, dy, dx, out); free(autocorrs); return out; } } free(autocorrs); return out; } double CO_Embed2_Basic_tau_incircle(const double y[], const int size, const double radius, const int tau) { int tauIntern = 0; if(tau < 0) { tauIntern = co_firstzero(y, size, size); } else{ tauIntern = tau; } double insidecount = 0; for(int i = 0; i < size-tauIntern; i++) { if(y[i]*y[i] + y[i+tauIntern]*y[i+tauIntern] < radius) { insidecount += 1; } } return insidecount/(size-tauIntern); } double CO_Embed2_Dist_tau_d_expfit_meandiff(const double y[], const int size) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } int tau = co_firstzero(y, size, size); //printf("co_firstzero ran\n"); if (tau > (double)size/10){ tau = floor((double)size/10); } //printf("tau = %i\n", tau); double * d = malloc((size-tau) * sizeof(double)); for(int i = 0; i < size-tau-1; i++) { d[i] = sqrt((y[i+1]-y[i])*(y[i+1]-y[i]) + (y[i+tau]-y[i+tau+1])*(y[i+tau]-y[i+tau+1])); //printf("d[%i]: %1.3f\n", i, d[i]); if (isnan(d[i])){ free(d); return NAN; } /* if(i<100) printf("%i, y[i]=%1.3f, y[i+1]=%1.3f, y[i+tau]=%1.3f, y[i+tau+1]=%1.3f, d[i]: %1.3f\n", i, y[i], y[i+1], y[i+tau], y[i+tau+1], d[i]); */ } //printf("embedding finished\n"); // mean for exponential fit double l = mean(d, size-tau-1); // count histogram bin contents /* int * histCounts; double * binEdges; int nBins = histcounts(d, size-tau-1, -1, &histCounts, &binEdges); */ int nBins = num_bins_auto(d, size-tau-1); if (nBins == 0){ return 0; } int * histCounts = malloc(nBins * sizeof(double)); double * binEdges = malloc((nBins + 1) * sizeof(double)); histcounts_preallocated(d, size-tau-1, nBins, histCounts, binEdges); //printf("histcount ran\n"); // normalise to probability double * histCountsNorm = malloc(nBins * sizeof(double)); for(int i = 0; i < nBins; i++){ //printf("histCounts %i: %i\n", i, histCounts[i]); histCountsNorm[i] = (double)histCounts[i]/(double)(size-tau-1); //printf("histCounts norm %i: %1.3f\n", i, histCountsNorm[i]); } /* for(int i = 0; i < nBins; i++){ printf("histCounts[%i] = %i\n", i, histCounts[i]); } for(int i = 0; i < nBins; i++){ printf("histCountsNorm[%i] = %1.3f\n", i, histCountsNorm[i]); } for(int i = 0; i < nBins+1; i++){ printf("binEdges[%i] = %1.3f\n", i, binEdges[i]); } */ //printf("histcounts normed\n"); double * d_expfit_diff = malloc(nBins * sizeof(double)); for(int i = 0; i < nBins; i++){ double expf = exp(-(binEdges[i] + binEdges[i+1])*0.5/l)/l; if (expf < 0){ expf = 0; } d_expfit_diff[i] = fabs(histCountsNorm[i]-expf); //printf("d_expfit_diff %i: %1.3f\n", i, d_expfit_diff[i]); } double out = mean(d_expfit_diff, nBins); //printf("out = %1.6f\n", out); //printf("reached free statements\n"); // arrays created dynamically in function histcounts free(d); free(d_expfit_diff); free(binEdges); free(histCountsNorm); free(histCounts); return out; } int CO_FirstMin_ac(const double y[], const int size) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return 0; } } double * autocorrs = co_autocorrs(y, size); int minInd = size; for(int i = 1; i < size-1; i++) { if(autocorrs[i] < autocorrs[i-1] && autocorrs[i] < autocorrs[i+1]) { minInd = i; break; } } free(autocorrs); return minInd; } double CO_trev_1_num(const double y[], const int size) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } int tau = 1; double * diffTemp = malloc((size-1) * sizeof * diffTemp); for(int i = 0; i < size-tau; i++) { diffTemp[i] = pow(y[i+1] - y[i],3); } double out; out = mean(diffTemp, size-tau); free(diffTemp); return out; } #define tau 2 #define numBins 5 double CO_HistogramAMI_even_2_5(const double y[], const int size) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } //const int tau = 2; //const int numBins = 5; double * y1 = malloc((size-tau) * sizeof(double)); double * y2 = malloc((size-tau) * sizeof(double)); for(int i = 0; i < size-tau; i++){ y1[i] = y[i]; y2[i] = y[i+tau]; } // set bin edges const double maxValue = max_(y, size); const double minValue = min_(y, size); double binStep = (maxValue - minValue + 0.2)/5; //double binEdges[numBins+1] = {0}; double binEdges[5+1] = {0}; for(int i = 0; i < numBins+1; i++){ binEdges[i] = minValue + binStep*i - 0.1; // printf("binEdges[%i] = %1.3f\n", i, binEdges[i]); } // count histogram bin contents int * bins1; bins1 = histbinassign(y1, size-tau, binEdges, numBins+1); int * bins2; bins2 = histbinassign(y2, size-tau, binEdges, numBins+1); /* // debug for(int i = 0; i < size-tau; i++){ printf("bins1[%i] = %i, bins2[%i] = %i\n", i, bins1[i], i, bins2[i]); } */ // joint double * bins12 = malloc((size-tau) * sizeof(double)); //double binEdges12[(numBins + 1) * (numBins + 1)] = {0}; double binEdges12[(5 + 1) * (5 + 1)] = {0}; for(int i = 0; i < size-tau; i++){ bins12[i] = (bins1[i]-1)*(numBins+1) + bins2[i]; // printf("bins12[%i] = %1.3f\n", i, bins12[i]); } for(int i = 0; i < (numBins+1)*(numBins+1); i++){ binEdges12[i] = i+1; // printf("binEdges12[%i] = %1.3f\n", i, binEdges12[i]); } // fancy solution for joint histogram here int * jointHistLinear; jointHistLinear = histcount_edges(bins12, size-tau, binEdges12, (numBins + 1) * (numBins + 1)); /* // debug for(int i = 0; i < (numBins+1)*(numBins+1); i++){ printf("jointHistLinear[%i] = %i\n", i, jointHistLinear[i]); } */ // transfer to 2D histogram (no last bin, as in original implementation) double pij[numBins][numBins]; int sumBins = 0; for(int i = 0; i < numBins; i++){ for(int j = 0; j < numBins; j++){ pij[j][i] = jointHistLinear[i*(numBins+1)+j]; // printf("pij[%i][%i]=%1.3f\n", i, j, pij[i][j]); sumBins += pij[j][i]; } } // normalise for(int i = 0; i < numBins; i++){ for(int j = 0; j < numBins; j++){ pij[j][i] /= sumBins; } } // marginals //double pi[numBins] = {0}; double pi[5] = {0}; //double pj[numBins] = {0}; double pj[5] = {0}; for(int i = 0; i < numBins; i++){ for(int j = 0; j < numBins; j++){ pi[i] += pij[i][j]; pj[j] += pij[i][j]; // printf("pij[%i][%i]=%1.3f, pi[%i]=%1.3f, pj[%i]=%1.3f\n", i, j, pij[i][j], i, pi[i], j, pj[j]); } } /* // debug for(int i = 0; i < numBins; i++){ printf("pi[%i]=%1.3f, pj[%i]=%1.3f\n", i, pi[i], i, pj[i]); } */ // mutual information double ami = 0; for(int i = 0; i < numBins; i++){ for(int j = 0; j < numBins; j++){ if(pij[i][j] > 0){ //printf("pij[%i][%i]=%1.3f, pi[%i]=%1.3f, pj[%i]=%1.3f, logarg=, %1.3f, log(...)=%1.3f\n", // i, j, pij[i][j], i, pi[i], j, pj[j], pij[i][j]/(pi[i]*pj[j]), log(pij[i][j]/(pi[i]*pj[j]))); ami += pij[i][j] * log(pij[i][j]/(pj[j]*pi[i])); } } } free(bins1); free(bins2); free(jointHistLinear); free(y1); free(y2); free(bins12); return ami; } ================================================ FILE: C/CO_AutoCorr.h ================================================ #ifndef CO_AUTOCORR_H #define CO_AUTOCORR_H #if __cplusplus # include typedef std::complex< double > cplx; #else # include #if defined(__GNUC__) || defined(__GNUG__) typedef double complex cplx; #elif defined(_MSC_VER) typedef _Dcomplex cplx; #endif #endif #include #include #include #include #include "stats.h" #include "fft.h" extern int nextpow2(int n); extern void dot_multiply(cplx a[], cplx b[], int size); extern double * CO_AutoCorr(const double y[], const int size, const int tau[], const int tau_size); extern double * co_autocorrs(const double y[], const int size); extern int co_firstzero(const double y[], const int size, const int maxtau); extern double CO_Embed2_Basic_tau_incircle(const double y[], const int size, const double radius, const int tau); extern double CO_Embed2_Dist_tau_d_expfit_meandiff(const double y[], const int size); extern int CO_FirstMin_ac(const double y[], const int size); extern double CO_trev_1_num(const double y[], const int size); extern double CO_f1ecac(const double y[], const int size); extern double CO_HistogramAMI_even_2_5(const double y[], const int size); #endif ================================================ FILE: C/DN_HistogramMode_10.c ================================================ #include #include #include #include #include "stats.h" #include "histcounts.h" double DN_HistogramMode_10(const double y[], const int size) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } const int nBins = 10; int * histCounts; double * binEdges; histcounts(y, size, nBins, &histCounts, &binEdges); double maxCount = 0; int numMaxs = 1; double out = 0;; for(int i = 0; i < nBins; i++) { // printf("binInd=%i, binCount=%i, binEdge=%1.3f \n", i, histCounts[i], binEdges[i]); if (histCounts[i] > maxCount) { maxCount = histCounts[i]; numMaxs = 1; out = (binEdges[i] + binEdges[i+1])*0.5; } else if (histCounts[i] == maxCount){ numMaxs += 1; out += (binEdges[i] + binEdges[i+1])*0.5; } } out = out/numMaxs; // arrays created dynamically in function histcounts free(histCounts); free(binEdges); return out; } /* double DN_HistogramMode_10(double y[], int size) { double min = DBL_MAX, max=-DBL_MAX; for(int i = 0; i < size; i++) { if (y[i] < min) { min = y[i]; } if (y[i] > max) { max = y[i]; } } double binStep = (max - min)/10; // fprintf(stdout, "min=%f, max=%f, binStep=%f \n", min, max, binStep); int histCounts[10] = {0}; for(int i = 0; i < size; i++) { int binsLeft = 10; int lowerInd = 0, upperInd = 10; while(binsLeft > 1) { int limitInd = (upperInd - lowerInd)/2 + lowerInd; double limit = limitInd * binStep + min; if (y[i] < limit) { upperInd = limitInd; } else { lowerInd = limitInd; } binsLeft = upperInd - lowerInd; } histCounts[lowerInd] += 1; } double maxCount = 0; int maxCountInd = 0; for(int i = 0; i < 10; i++) { // fprintf(stdout, "binInd=%i, binCount=%i \n", i, histCounts[i]); if (histCounts[i] > maxCount) { maxCountInd = i; maxCount = histCounts[i]; } } return binStep*(maxCountInd+0.5) + min; } */ ================================================ FILE: C/DN_HistogramMode_10.h ================================================ #ifndef DN_HISTOGRAMMODE_10 #define DN_HISTOGRAMMODE_10 #include #include #include "stats.h" extern double DN_HistogramMode_10(const double y[], const int size); #endif ================================================ FILE: C/DN_HistogramMode_5.c ================================================ #include #include #include #include #include "stats.h" #include "histcounts.h" double DN_HistogramMode_5(const double y[], const int size) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } const int nBins = 5; int * histCounts; double * binEdges; histcounts(y, size, nBins, &histCounts, &binEdges); /* for(int i = 0; i < nBins; i++){ printf("histCounts[%i] = %i\n", i, histCounts[i]); } for(int i = 0; i < nBins+1; i++){ printf("binEdges[%i] = %1.3f\n", i, binEdges[i]); } */ double maxCount = 0; int numMaxs = 1; double out = 0;; for(int i = 0; i < nBins; i++) { // printf("binInd=%i, binCount=%i, binEdge=%1.3f \n", i, histCounts[i], binEdges[i]); if (histCounts[i] > maxCount) { maxCount = histCounts[i]; numMaxs = 1; out = (binEdges[i] + binEdges[i+1])*0.5; } else if (histCounts[i] == maxCount){ numMaxs += 1; out += (binEdges[i] + binEdges[i+1])*0.5; } } out = out/numMaxs; // arrays created dynamically in function histcounts free(histCounts); free(binEdges); return out; } /* double DN_HistogramMode_5(double y[], int size) { double min = DBL_MAX, max=-DBL_MAX; for(int i = 0; i < size; i++) { if (y[i] < min) { min = y[i]; } if (y[i] > max) { max = y[i]; } } double binStep = (max - min)/5; // fprintf(stdout, "min=%f, max=%f, binStep=%f \n", min, max, binStep); int histCounts[5] = {0}; for(int i = 0; i < size; i++) { int binsLeft = 5; int lowerInd = 0, upperInd = 10; while(binsLeft > 1) { int limitInd = (upperInd - lowerInd)/2 + lowerInd; double limit = limitInd * binStep + min; if (y[i] < limit) { upperInd = limitInd; } else { lowerInd = limitInd; } binsLeft = upperInd - lowerInd; } histCounts[lowerInd] += 1; } double maxCount = 0; int maxCountInd = 0; for(int i = 0; i < 5; i++) { // fprintf(stdout, "binInd=%i, binCount=%i \n", i, histCounts[i]); if (histCounts[i] > maxCount) { maxCountInd = i; maxCount = histCounts[i]; } } return binStep*(maxCountInd+0.5) + min; } */ ================================================ FILE: C/DN_HistogramMode_5.h ================================================ #ifndef DN_HISTOGRAMMODE_5 #define DN_HISTOGRAMMODE_5 #include #include #include "stats.h" extern double DN_HistogramMode_5(const double y[], const int size); #endif ================================================ FILE: C/DN_Mean.c ================================================ #include double DN_Mean(const double a[], const int size) { double m = 0.0; for (int i = 0; i < size; i++) { m += a[i]; } m /= size; return m; } ================================================ FILE: C/DN_Mean.h ================================================ // // Created by Trent Henderson 27 September 2021 // #ifndef DN_MEAN #define DN_MEAN #include extern double DN_Mean(const double a[], const int size); #endif /* DN_MEAN */ ================================================ FILE: C/DN_OutlierInclude.c ================================================ #include #include #include #include #include #include #include "stats.h" double DN_OutlierInclude_np_001_mdrmd(const double y[], const int size, const int sign) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } double inc = 0.01; int tot = 0; double * yWork = malloc(size * sizeof(double)); // apply sign and check constant time series int constantFlag = 1; for(int i = 0; i < size; i++) { if(y[i] != y[0]) { constantFlag = 0; } // apply sign, save in new variable yWork[i] = sign*y[i]; // count pos/ negs if(yWork[i] >= 0){ tot += 1; } } if(constantFlag){ free(yWork); return 0; // if constant, return 0 } // find maximum (or minimum, depending on sign) double maxVal = max_(yWork, size); // maximum value too small? return 0 if(maxVal < inc){ free(yWork); return 0; } int nThresh = maxVal/inc + 1; // save the indices where y > threshold double * r = malloc(size * sizeof * r); // save the median over indices with absolute value > threshold double * msDti1 = malloc(nThresh * sizeof(double)); double * msDti3 = malloc(nThresh * sizeof(double)); double * msDti4 = malloc(nThresh * sizeof(double)); for(int j = 0; j < nThresh; j++) { //printf("j=%i, thr=%1.3f\n", j, j*inc); int highSize = 0; for(int i = 0; i < size; i++) { if(yWork[i] >= j*inc) { r[highSize] = i+1; //printf("r[%i]=%1.f \n", highSize, r[highSize]); highSize += 1; } } // intervals between high-values double * Dt_exc = malloc(highSize * sizeof(double)); for(int i = 0; i < highSize-1; i++) { //printf("i=%i, r[i+1]=%1.f, r[i]=%1.f \n", i, r[i+1], r[i]); Dt_exc[i] = r[i+1] - r[i]; } /* // median double medianOut; medianOut = median(r, highSize); */ msDti1[j] = mean(Dt_exc, highSize-1); msDti3[j] = (highSize-1)*100.0/tot; msDti4[j] = median(r, highSize) / ((double)size/2) - 1; //printf("msDti1[%i] = %1.3f, msDti13[%i] = %1.3f, msDti4[%i] = %1.3f\n", // j, msDti1[j], j, msDti3[j], j, msDti4[j]); free(Dt_exc); } int trimthr = 2; int mj = 0; int fbi = nThresh-1; for(int i = 0; i < nThresh; i ++) { if (msDti3[i] > trimthr) { mj = i; } if (isnan(msDti1[nThresh-1-i])) { fbi = nThresh-1-i; } } double outputScalar; int trimLimit = mj < fbi ? mj : fbi; outputScalar = median(msDti4, trimLimit+1); free(r); free(yWork); free(msDti1); free(msDti3); free(msDti4); return outputScalar; } double DN_OutlierInclude_p_001_mdrmd(const double y[], const int size) { return DN_OutlierInclude_np_001_mdrmd(y, size, 1.0); } double DN_OutlierInclude_n_001_mdrmd(const double y[], const int size) { return DN_OutlierInclude_np_001_mdrmd(y, size, -1.0); } double DN_OutlierInclude_abs_001(const double y[], const int size) { double inc = 0.01; double maxAbs = 0; double * yAbs = malloc(size * sizeof * yAbs); for(int i = 0; i < size; i++) { // yAbs[i] = (y[i] > 0) ? y[i] : -y[i]; yAbs[i] = (y[i] > 0) ? y[i] : -y[i]; if(yAbs[i] > maxAbs) { maxAbs = yAbs[i]; } } int nThresh = maxAbs/inc + 1; printf("nThresh = %i\n", nThresh); // save the indices where y > threshold double * highInds = malloc(size * sizeof * highInds); // save the median over indices with absolute value > threshold double * msDti3 = malloc(nThresh * sizeof * msDti3); double * msDti4 = malloc(nThresh * sizeof * msDti4); for(int j = 0; j < nThresh; j++) { int highSize = 0; for(int i = 0; i < size; i++) { if(yAbs[i] >= j*inc) { // fprintf(stdout, "%i, ", i); highInds[highSize] = i; highSize += 1; } } // median double medianOut; medianOut = median(highInds, highSize); msDti3[j] = (highSize-1)*100.0/size; msDti4[j] = medianOut / (size/2) - 1; } int trimthr = 2; int mj = 0; for(int i = 0; i < nThresh; i ++) { if (msDti3[i] > trimthr) { mj = i; } } double outputScalar; outputScalar = median(msDti4, mj); free(highInds); free(yAbs); free(msDti4); return outputScalar; } ================================================ FILE: C/DN_OutlierInclude.h ================================================ #ifndef DN_OUTLIERINCLUDE_ABS_001 #define DN_OUTLIERINCLUDE_ABS_001 #include #include #include #include #include "stats.h" extern double DN_OutlierInclude_abs_001(const double y[], const int size); extern double DN_OutlierInclude_np_001_mdrmd(const double y[], const int size, const int sign); extern double DN_OutlierInclude_p_001_mdrmd(const double y[], const int size); extern double DN_OutlierInclude_n_001_mdrmd(const double y[], const int size); #endif ================================================ FILE: C/DN_Spread_Std.c ================================================ #include #include "stats.h" double DN_Spread_Std(const double a[], const int size) { double m = mean(a, size); double sd = 0.0; for (int i = 0; i < size; i++) { sd += pow(a[i] - m, 2); } sd = sqrt(sd / (size - 1)); return sd; } ================================================ FILE: C/DN_Spread_Std.h ================================================ // // Created by Trent Henderson 27 September 2021 // #ifndef DN_SPREADSTD #define DN_SPREADSTD #include extern double DN_Spread_Std(const double a[], const int size); #endif /* DN_SPREADSTD */ ================================================ FILE: C/FC_LocalSimple.c ================================================ #include #include #include "stats.h" #include "CO_AutoCorr.h" static void abs_diff(const double a[], const int size, double b[]) { for (int i = 1; i < size; i++) { b[i - 1] = fabs(a[i] - a[i - 1]); } } double fc_local_simple(const double y[], const int size, const int train_length) { double * y1 = malloc((size - 1) * sizeof *y1); abs_diff(y, size, y1); double m = mean(y1, size - 1); free(y1); return m; } double FC_LocalSimple_mean_tauresrat(const double y[], const int size, const int train_length) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } double * res = malloc((size - train_length) * sizeof *res); for (int i = 0; i < size - train_length; i++) { double yest = 0; for (int j = 0; j < train_length; j++) { yest += y[i+j]; } yest /= train_length; res[i] = y[i+train_length] - yest; } double resAC1stZ = co_firstzero(res, size - train_length, size - train_length); double yAC1stZ = co_firstzero(y, size, size); double output = resAC1stZ/yAC1stZ; free(res); return output; } double FC_LocalSimple_mean_stderr(const double y[], const int size, const int train_length) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } double * res = malloc((size - train_length) * sizeof *res); for (int i = 0; i < size - train_length; i++) { double yest = 0; for (int j = 0; j < train_length; j++) { yest += y[i+j]; } yest /= train_length; res[i] = y[i+train_length] - yest; } double output = stddev(res, size - train_length); free(res); return output; } double FC_LocalSimple_mean3_stderr(const double y[], const int size) { return FC_LocalSimple_mean_stderr(y, size, 3); } double FC_LocalSimple_mean1_tauresrat(const double y[], const int size){ return FC_LocalSimple_mean_tauresrat(y, size, 1); } double FC_LocalSimple_mean_taures(const double y[], const int size, const int train_length) { double * res = malloc((size - train_length) * sizeof *res); // first z-score // no, assume ts is z-scored!! //zscore_norm(y, size); for (int i = 0; i < size - train_length; i++) { double yest = 0; for (int j = 0; j < train_length; j++) { yest += y[i+j]; } yest /= train_length; res[i] = y[i+train_length] - yest; } int output = co_firstzero(res, size - train_length, size - train_length); free(res); return output; } double FC_LocalSimple_lfit_taures(const double y[], const int size) { // set tau from first AC zero crossing int train_length = co_firstzero(y, size, size); double * xReg = malloc(train_length * sizeof * xReg); // double * yReg = malloc(train_length * sizeof * yReg); for(int i = 1; i < train_length+1; i++) { xReg[i-1] = i; } double * res = malloc((size - train_length) * sizeof *res); double m = 0.0, b = 0.0; for (int i = 0; i < size - train_length; i++) { linreg(train_length, xReg, y+i, &m, &b); // fprintf(stdout, "i=%i, m=%f, b=%f\n", i, m, b); res[i] = y[i+train_length] - (m * (train_length+1) + b); } int output = co_firstzero(res, size - train_length, size - train_length); free(res); free(xReg); // free(yReg); return output; } ================================================ FILE: C/FC_LocalSimple.h ================================================ #ifndef FC_LOCALSIMPLE_H #define FC_LOCALSIMPLE_H #include #include #include "stats.h" #include "CO_AutoCorr.h" extern double fc_local_simple(const double y[], const int size, const int train_length); extern double FC_LocalSimple_mean_taures(const double y[], const int size, const int train_length); extern double FC_LocalSimple_lfit_taures(const double y[], const int size); extern double FC_LocalSimple_mean_tauresrat(const double y[], const int size, const int train_length); extern double FC_LocalSimple_mean1_tauresrat(const double y[], const int size); extern double FC_LocalSimple_mean_stderr(const double y[], const int size, const int train_length); extern double FC_LocalSimple_mean3_stderr(const double y[], const int size); #endif ================================================ FILE: C/IN_AutoMutualInfoStats.c ================================================ // // IN_AutoMutualInfoStats.c // C_polished // // Created by Carl Henning Lubba on 22/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #include #include "IN_AutoMutualInfoStats.h" #include "CO_AutoCorr.h" #include "stats.h" double IN_AutoMutualInfoStats_40_gaussian_fmmi(const double y[], const int size) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } // maximum time delay int tau = 40; // don't go above half the signal length if(tau > ceil((double)size/2)){ tau = ceil((double)size/2); } // compute autocorrelations and compute automutual information double * ami = malloc(size * sizeof(double)); for(int i = 0; i < tau; i++){ double ac = autocorr_lag(y,size, i+1); ami[i] = -0.5 * log(1 - ac*ac); // printf("ami[%i]=%1.7f\n", i, ami[i]); } // find first minimum of automutual information double fmmi = tau; for(int i = 1; i < tau-1; i++){ if(ami[i] < ami[i-1] & ami[i] < ami[i+1]){ fmmi = i; // printf("found minimum at %i\n", i); break; } } free(ami); return fmmi; } ================================================ FILE: C/IN_AutoMutualInfoStats.h ================================================ // // IN_AutoMutualInfoStats.h // C_polished // // Created by Carl Henning Lubba on 22/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #ifndef IN_AutoMutualInfoStats_h #define IN_AutoMutualInfoStats_h #include extern double IN_AutoMutualInfoStats_40_gaussian_fmmi(const double y[], const int size); #endif /* IN_AutoMutualInfoStats_h */ ================================================ FILE: C/MD_hrv.c ================================================ // // MD_hrv.c // C_polished // // Created by Carl Henning Lubba on 22/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #include "MD_hrv.h" #include "stats.h" double MD_hrv_classic_pnn40(const double y[], const int size){ // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } const int pNNx = 40; // compute diff double * Dy = malloc((size-1) * sizeof(double)); diff(y, size, Dy); double pnn40 = 0; for(int i = 0; i < size-1; i++){ if(fabs(Dy[i])*1000 > pNNx){ pnn40 += 1; } } free(Dy); return pnn40/(size-1); } ================================================ FILE: C/MD_hrv.h ================================================ // // MD_hrv.h // C_polished // // Created by Carl Henning Lubba on 22/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #ifndef MD_hrv_h #define MD_hrv_h #include extern double MD_hrv_classic_pnn40(const double y[], const int size); #endif /* MD_hrv_h */ ================================================ FILE: C/PD_PeriodicityWang.c ================================================ // // PD_PeriodicityWang.c // C_polished // // Created by Carl Henning Lubba on 28/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #include #include #include "PD_PeriodicityWang.h" #include "splinefit.h" #include "stats.h" int PD_PeriodicityWang_th0_01(const double * y, const int size){ // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return 0; } } const double th = 0.01; double * ySpline = malloc(size * sizeof(double)); // fit a spline with 3 nodes to the data splinefit(y, size, ySpline); //printf("spline fit complete.\n"); // subtract spline from data to remove trend double * ySub = malloc(size * sizeof(double)); for(int i = 0; i < size; i++){ ySub[i] = y[i] - ySpline[i]; //printf("ySub[%i] = %1.5f\n", i, ySub[i]); } // compute autocorrelations up to 1/3 of the length of the time series int acmax = (int)ceil((double)size/3); double * acf = malloc(acmax*sizeof(double)); for(int tau = 1; tau <= acmax; tau++){ // correlation/ covariance the same, don't care for scaling (cov would be more efficient) acf[tau-1] = autocov_lag(ySub, size, tau); //printf("acf[%i] = %1.9f\n", tau-1, acf[tau-1]); } //printf("ACF computed.\n"); // find troughts and peaks double * troughs = malloc(acmax * sizeof(double)); double * peaks = malloc(acmax * sizeof(double)); int nTroughs = 0; int nPeaks = 0; double slopeIn = 0; double slopeOut = 0; for(int i = 1; i < acmax-1; i ++){ slopeIn = acf[i] - acf[i-1]; slopeOut = acf[i+1] - acf[i]; if(slopeIn < 0 & slopeOut > 0) { // printf("trough at %i\n", i); troughs[nTroughs] = i; nTroughs += 1; } else if(slopeIn > 0 & slopeOut < 0) { // printf("peak at %i\n", i); peaks[nPeaks] = i; nPeaks += 1; } } //printf("%i troughs and %i peaks found.\n", nTroughs, nPeaks); // search through all peaks for one that meets the conditions: // (a) a trough before it // (b) difference between peak and trough is at least 0.01 // (c) peak corresponds to positive correlation int iPeak = 0; double thePeak = 0; int iTrough = 0; double theTrough = 0; int out = 0; for(int i = 0; i < nPeaks; i++){ iPeak = peaks[i]; thePeak = acf[iPeak]; //printf("i=%i/%i, iPeak=%i, thePeak=%1.3f\n", i, nPeaks-1, iPeak, thePeak); // find trough before this peak int j = -1; while(troughs[j+1] < iPeak && j+1 < nTroughs){ // printf("j=%i/%i, iTrough=%i, theTrough=%1.3f\n", j+1, nTroughs-1, (int)troughs[j+1], acf[(int)troughs[j+1]]); j++; } if(j == -1) continue; iTrough = troughs[j]; theTrough = acf[iTrough]; // (a) should be implicit // (b) different between peak and trough it as least 0.01 if(thePeak - theTrough < th) continue; // (c) peak corresponds to positive correlation if(thePeak < 0) continue; // use this frequency that first fulfils all conditions. out = iPeak; break; } //printf("Before freeing stuff.\n"); free(ySpline); free(ySub); free(acf); free(troughs); free(peaks); return out; } ================================================ FILE: C/PD_PeriodicityWang.h ================================================ // // PD_PeriodicityWang.h // C_polished // // Created by Carl Henning Lubba on 28/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #ifndef PD_PeriodicityWang_h #define PD_PeriodicityWang_h #include extern int PD_PeriodicityWang_th0_01(const double * y, const int size); #endif /* PD_PeriodicityWang_h */ ================================================ FILE: C/SB_BinaryStats.c ================================================ // // SB_BinaryStats.c // C_polished // // Created by Carl Henning Lubba on 22/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #include "SB_BinaryStats.h" #include "stats.h" double SB_BinaryStats_diff_longstretch0(const double y[], const int size){ // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } // binarize int * yBin = malloc((size-1) * sizeof(int)); for(int i = 0; i < size-1; i++){ double diffTemp = y[i+1] - y[i]; yBin[i] = diffTemp < 0 ? 0 : 1; /* if( i < 300) printf("%i, y[i+1]=%1.3f, y[i]=%1.3f, yBin[i]=%i\n", i, y[i+1], y[i], yBin[i]); */ } int maxstretch0 = 0; int last1 = 0; for(int i = 0; i < size-1; i++){ if(yBin[i] == 1 | i == size-2){ double stretch0 = i - last1; if(stretch0 > maxstretch0){ maxstretch0 = stretch0; } last1 = i; } } free(yBin); return maxstretch0; } double SB_BinaryStats_mean_longstretch1(const double y[], const int size){ // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } // binarize int * yBin = malloc((size-1) * sizeof(int)); double yMean = mean(y, size); for(int i = 0; i < size-1; i++){ yBin[i] = (y[i] - yMean <= 0) ? 0 : 1; //printf("yBin[%i]=%i\n", i, yBin[i]); } int maxstretch1 = 0; int last1 = 0; for(int i = 0; i < size-1; i++){ if(yBin[i] == 0 | i == size-2){ double stretch1 = i - last1; if(stretch1 > maxstretch1){ maxstretch1 = stretch1; } last1 = i; } } free(yBin); return maxstretch1; } ================================================ FILE: C/SB_BinaryStats.h ================================================ // // SB_BinaryStats.h // C_polished // // Created by Carl Henning Lubba on 22/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #ifndef SB_BinaryStats_h #define SB_BinaryStats_h #include extern double SB_BinaryStats_diff_longstretch0(const double y[], const int size); extern double SB_BinaryStats_mean_longstretch1(const double y[], const int size); #endif /* SB_BinaryStats_h */ ================================================ FILE: C/SB_CoarseGrain.c ================================================ #include #include #include #include #include "stats.h" #include "helper_functions.h" void sb_coarsegrain(const double y[], const int size, const char how[], const int num_groups, int labels[]) { int i, j; if (strcmp(how, "quantile") == 1) { fprintf(stdout, "ERROR in sb_coarsegrain: unknown coarse-graining method\n"); exit(1); } /* for(int i = 0; i < size; i++){ printf("yin coarsegrain[%i]=%1.4f\n", i, y[i]); } */ double * th = malloc((num_groups + 1) * 2 * sizeof(th)); double * ls = malloc((num_groups + 1) * 2 * sizeof(th)); linspace(0, 1, num_groups + 1, ls); for (i = 0; i < num_groups + 1; i++) { //double quant = quantile(y, size, ls[i]); th[i] = quantile(y, size, ls[i]); } th[0] -= 1; for (i = 0; i < num_groups; i++) { for (j = 0; j < size; j++) { if (y[j] > th[i] && y[j] <= th[i + 1]) { labels[j] = i + 1; } } } free(th); free(ls); } ================================================ FILE: C/SB_CoarseGrain.h ================================================ #ifndef SB_COARSEGRAIN_H #define SB_COARSEGRAIN_H #include #include #include #include #include "stats.h" #include "helper_functions.h" extern void sb_coarsegrain(const double y[], const int size, const char how[], const int num_groups, int labels[]); #endif ================================================ FILE: C/SB_MotifThree.c ================================================ #include #include #include #include #include "SB_CoarseGrain.h" #include "helper_functions.h" double SB_MotifThree_quantile_hh(const double y[], const int size) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } int tmp_idx, r_idx; int dynamic_idx; int alphabet_size = 3; int array_size; int * yt = malloc(size * sizeof(yt)); // alphabetized array double hh; // output double * out = malloc(124 * sizeof(out)); // output array // transfer to alphabet sb_coarsegrain(y, size, "quantile", 3, yt); // words of length 1 array_size = alphabet_size; int ** r1 = malloc(array_size * sizeof(*r1)); int * sizes_r1 = malloc(array_size * sizeof(sizes_r1)); double * out1 = malloc(array_size * sizeof(out1)); for (int i = 0; i < alphabet_size; i++) { r1[i] = malloc(size * sizeof(r1[i])); // probably can be rewritten // using selfresizing array for memory efficiency. Time complexity // should be comparable due to ammotization. r_idx = 0; sizes_r1[i] = 0; for (int j = 0; j < size; j++) { if (yt[j] == i + 1) { r1[i][r_idx++] = j; sizes_r1[i]++; } } } // words of length 2 array_size *= alphabet_size; // removing last item if it is == max possible idx since later we are taking idx + 1 // from yt for (int i = 0; i < alphabet_size; i++) { if (sizes_r1[i] != 0 && r1[i][sizes_r1[i] - 1] == size - 1) { //int * tmp_ar = malloc((sizes_r1[i] - 1) * sizeof(tmp_ar)); int* tmp_ar = malloc(sizes_r1[i] * sizeof(tmp_ar)); subset(r1[i], tmp_ar, 0, sizes_r1[i]); memcpy(r1[i], tmp_ar, (sizes_r1[i] - 1) * sizeof(tmp_ar)); sizes_r1[i]--; free(tmp_ar); } } /* int *** r2 = malloc(array_size * sizeof(**r2)); int ** sizes_r2 = malloc(array_size * sizeof(*sizes_r2)); double ** out2 = malloc(array_size * sizeof(*out2)); */ int*** r2 = malloc(alphabet_size * sizeof(**r2)); int** sizes_r2 = malloc(alphabet_size * sizeof(*sizes_r2)); double** out2 = malloc(alphabet_size * sizeof(*out2)); // allocate separately for (int i = 0; i < alphabet_size; i++) { r2[i] = malloc(alphabet_size * sizeof(*r2[i])); sizes_r2[i] = malloc(alphabet_size * sizeof(*sizes_r2[i])); //out2[i] = malloc(alphabet_size * sizeof(out2[i])); out2[i] = malloc(alphabet_size * sizeof(**out2)); for (int j = 0; j < alphabet_size; j++) { r2[i][j] = malloc(size * sizeof(*r2[i][j])); } } // fill separately for (int i = 0; i < alphabet_size; i++) { // for (int i = 0; i < array_size; i++) { //r2[i] = malloc(alphabet_size * sizeof(r2[i])); //sizes_r2[i] = malloc(alphabet_size * sizeof(sizes_r2[i])); //out2[i] = malloc(alphabet_size * sizeof(out2[i])); for (int j = 0; j < alphabet_size; j++) { //r2[i][j] = malloc(size * sizeof(r2[i][j])); sizes_r2[i][j] = 0; dynamic_idx = 0; //workaround as you can't just add elements to array // like in python (list.append()) for example, so since for some k there will be no adding, // you need to keep track of the idx at which elements will be inserted for (int k = 0; k < sizes_r1[i]; k++) { tmp_idx = yt[r1[i][k] + 1]; if (tmp_idx == (j + 1)) { r2[i][j][dynamic_idx++] = r1[i][k]; sizes_r2[i][j]++; // printf("dynamic_idx=%i, size = %i\n", dynamic_idx, size); } } double tmp = (double)sizes_r2[i][j] / ((double)(size) - (double)(1.0)); out2[i][j] = tmp; } } hh = 0.0; for (int i = 0; i < alphabet_size; i++) { hh += f_entropy(out2[i], alphabet_size); } free(yt); free(out); free(out1); free(sizes_r1); // free nested array for (int i = 0; i < alphabet_size; i++) { free(r1[i]); } free(r1); // free(sizes_r1); for (int i = 0; i < alphabet_size; i++) { //for (int i = alphabet_size - 1; i >= 0; i--) { free(sizes_r2[i]); free(out2[i]); } //for (int i = alphabet_size-1; i >= 0 ; i--) { for(int i = 0; i < alphabet_size; i++) { for (int j = 0; j < alphabet_size; j++) { free(r2[i][j]); } free(r2[i]); } free(r2); free(sizes_r2); free(out2); return hh; } double * sb_motifthree(const double y[], int size, const char how[]) { int tmp_idx, r_idx, i, j, k, l, m, array_size; int dynamic_idx; int * tmp_ar; int alphabet_size = 3; int out_idx = 0; int * yt = malloc(size * sizeof(yt)); double tmp; double * out = malloc(124 * sizeof(out)); // output array if (strcmp(how, "quantile") == 0) { sb_coarsegrain(y, size, how, alphabet_size, yt); } else if (strcmp(how, "diffquant") == 0) { double * diff_y = malloc((size - 1) * sizeof(diff_y)); diff(y, size, diff_y); sb_coarsegrain(diff_y, size, how, alphabet_size, yt); size--; } else { fprintf(stdout, "ERROR in sb_motifthree: Unknown how method"); exit(1); } // words of length 1 array_size = alphabet_size; int ** r1 = malloc(array_size * sizeof(*r1)); int * sizes_r1 = malloc(array_size * sizeof(sizes_r1)); double * out1 = malloc(array_size * sizeof(out1)); for (i = 0; i < array_size; i++) { r1[i] = malloc(size * sizeof(r1[i])); // probably can be rewritten // using selfresizing array for memory efficiency. Time complexity // should be comparable due to ammotization. r_idx = 0; sizes_r1[i] = 0; for (j = 0; j < size; j++) { if (yt[j] == i + 1) { r1[i][r_idx++] = j; sizes_r1[i]++; } } tmp = (double)sizes_r1[i] / size; out1[i] = tmp; out[out_idx++] = tmp; } out[out_idx++] = f_entropy(out1, array_size); // words of length 2 array_size *= alphabet_size; // removing last item if it is == max possible idx since later we are taking idx + 1 // from yt for (i = 0; i < alphabet_size; i++) { if (sizes_r1[i] != 0 && r1[i][sizes_r1[i] - 1] == size - 1) { tmp_ar = malloc((sizes_r1[i] - 1) * sizeof(tmp_ar)); subset(r1[i], tmp_ar, 0, sizes_r1[i]); memcpy(r1[i], tmp_ar, (sizes_r1[i] - 1) * sizeof(tmp_ar)); sizes_r1[i]--; } } int *** r2 = malloc(array_size * sizeof(**r2)); int ** sizes_r2 = malloc(array_size * sizeof(*sizes_r2)); double ** out2 = malloc(array_size * sizeof(*out2)); for (i = 0; i < alphabet_size; i++) { r2[i] = malloc(alphabet_size * sizeof(r2[i])); sizes_r2[i] = malloc(alphabet_size * sizeof(sizes_r2[i])); out2[i] = malloc(alphabet_size * sizeof(out2[i])); for (j = 0; j < alphabet_size; j++) { r2[i][j] = malloc(size * sizeof(r2[i][j])); sizes_r2[i][j] = 0; dynamic_idx = 0; //workaround as you can't just add elements to array // like in python (list.append()) for example, so since for some k there will be no adding, // you need to keep track of the idx at which elements will be inserted for (k = 0; k < sizes_r1[i]; k++) { tmp_idx = yt[r1[i][k] + 1]; if (tmp_idx == (j + 1)) { r2[i][j][dynamic_idx++] = r1[i][k]; sizes_r2[i][j]++; } } tmp = (double)sizes_r2[i][j] / (size - 1); out2[i][j] = tmp; out[out_idx++] = tmp; } } tmp = 0.0; for (i = 0; i < alphabet_size; i++) { tmp += f_entropy(out2[i], alphabet_size); } out[out_idx++] = tmp; // words of length 3 array_size *= alphabet_size; for (i = 0; i < alphabet_size; i++) { for (j = 0; j < alphabet_size; j++) { if (sizes_r2[i][j] != 0 && r2[i][j][sizes_r2[i][j] - 1] == size - 2) { subset(r2[i][j], tmp_ar, 0, sizes_r2[i][j]); memcpy(r2[i][j], tmp_ar, (sizes_r2[i][j] - 1) * sizeof(tmp_ar)); sizes_r2[i][j]--; } } } int **** r3 = malloc(array_size * sizeof(***r3)); int *** sizes_r3 = malloc(array_size * sizeof(**sizes_r3)); double *** out3 = malloc(array_size * sizeof(**out3)); for (i = 0; i < alphabet_size; i++) { r3[i] = malloc(alphabet_size * sizeof(r3[i])); sizes_r3[i] = malloc(alphabet_size * sizeof(sizes_r3[i])); out3[i] = malloc(alphabet_size * sizeof(out3[i])); for (j = 0; j < alphabet_size; j++) { r3[i][j] = malloc(alphabet_size * sizeof(r3[i][j])); sizes_r3[i][j] = malloc(alphabet_size * sizeof(sizes_r3[i][j])); out3[i][j] = malloc(alphabet_size * sizeof(out3[i][j])); for (k = 0; k < alphabet_size; k++) { r3[i][j][k] = malloc(size * sizeof(r3[i][j][k])); sizes_r3[i][j][k] = 0; dynamic_idx = 0; for (l = 0; l < sizes_r2[i][j]; l++) { tmp_idx = yt[r2[i][j][l] + 2]; if (tmp_idx == (k + 1)) { r3[i][j][k][dynamic_idx++] = r2[i][j][l]; sizes_r3[i][j][k]++; } } tmp = (double)sizes_r3[i][j][k] / (size - 2); out3[i][j][k] = tmp; out[out_idx++] = tmp; } } } tmp = 0.0; for (i = 0; i < alphabet_size; i++) { for (j = 0; j < alphabet_size; j++) { tmp += f_entropy(out3[i][j], alphabet_size); } } out[out_idx++] = tmp; // words of length 4 array_size *= alphabet_size; for (i = 0; i < alphabet_size; i++) { for (j = 0; j < alphabet_size; j++) { for (k = 0; k < alphabet_size; k++) { if (sizes_r3[i][j][k] != 0 && r3[i][j][k][sizes_r3[i][j][k] - 1] == size - 3) { subset(r3[i][j][k], tmp_ar, 0, sizes_r3[i][j][k]); memcpy(r3[i][j][k], tmp_ar, (sizes_r3[i][j][k] - 1) * sizeof(tmp_ar)); sizes_r3[i][j][k]--; } } } } int ***** r4 = malloc(array_size * sizeof(****r4)); // just an array of pointers of array of pointers of array of pointers // of array of pointers of array of ints... We need to go deeper (c) int **** sizes_r4 = malloc(array_size * sizeof(***sizes_r3)); double **** out4 = malloc(array_size * sizeof(***out4)); for (i = 0; i < alphabet_size; i++) { r4[i] = malloc(alphabet_size * sizeof(r4[i])); sizes_r4[i] = malloc(alphabet_size * sizeof(sizes_r4[i])); out4[i] = malloc(alphabet_size * sizeof(out4[i])); for (j = 0; j < alphabet_size; j++) { r4[i][j] = malloc(alphabet_size * sizeof(r4[i][j])); sizes_r4[i][j] = malloc(alphabet_size * sizeof(sizes_r4[i][j])); out4[i][j] = malloc(alphabet_size * sizeof(out4[i][j])); for (k = 0; k < alphabet_size; k++) { r4[i][j][k] = malloc(alphabet_size * sizeof(r4[i][j][k])); sizes_r4[i][j][k] = malloc(alphabet_size * sizeof(sizes_r4[i][j][k])); out4[i][j][k] = malloc(alphabet_size * sizeof(out4[i][j][k])); for (l = 0; l < alphabet_size; l++) { r4[i][j][k][l] = malloc(size * sizeof(r4[i][j][k][l])); sizes_r4[i][j][k][l] = 0; dynamic_idx = 0; for (m = 0; m < sizes_r3[i][j][k]; m++) { tmp_idx = yt[r3[i][j][k][m] + 3]; if (tmp_idx == l + 1) { r4[i][j][k][l][dynamic_idx++] = r3[i][j][k][m]; sizes_r4[i][j][k][l]++; } } tmp = (double)sizes_r4[i][j][k][l] / (size - 3); out4[i][j][k][l] = tmp; out[out_idx++] = tmp; } } } } tmp = 0.0; for (i = 0; i < alphabet_size; i++) { for (j = 0; j < alphabet_size; j++) { for (k = 0; k < alphabet_size; k++) { tmp += f_entropy(out4[i][j][k], alphabet_size); } } } out[out_idx++] = tmp; return out; } ================================================ FILE: C/SB_MotifThree.h ================================================ #ifndef SB_MOTIFTHREE_H #define SB_MOTIFTHREE_H #include #include #include #include "SB_CoarseGrain.h" #include "helper_functions.h" extern double SB_MotifThree_quantile_hh(const double y[], const int size); extern double * sb_motifthree(const double y[], int size, const char how[]); #endif ================================================ FILE: C/SB_TransitionMatrix.c ================================================ // // SB_TransitionMatrix.c // // // Created by Carl Henning Lubba on 23/09/2018. // #include "SB_TransitionMatrix.h" #include "butterworth.h" #include "CO_AutoCorr.h" #include "SB_CoarseGrain.h" #include "stats.h" double SB_TransitionMatrix_3ac_sumdiagcov(const double y[], const int size) { // NaN and const check int constant = 1; for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } if(y[i] != y[0]){ constant = 0; } } if (constant){ return NAN; } const int numGroups = 3; int tau = co_firstzero(y, size, size); double * yFilt = malloc(size * sizeof(double)); // sometimes causes problems in filt!!! needs fixing. /* if(tau > 1){ butterworthFilter(y, size, 4, 0.8/tau, yFilt); } */ for(int i = 0; i < size; i++){ yFilt[i] = y[i]; } /* for(int i = 0; i < size; i++){ printf("yFilt[%i]=%1.4f\n", i, yFilt[i]); } */ int nDown = (size-1)/tau+1; double * yDown = malloc(nDown * sizeof(double)); for(int i = 0; i < nDown; i++){ yDown[i] = yFilt[i*tau]; } /* for(int i = 0; i < nDown; i++){ printf("yDown[%i]=%1.4f\n", i, yDown[i]); } */ // transfer to alphabet int * yCG = malloc(nDown * sizeof(double)); sb_coarsegrain(yDown, nDown, "quantile", numGroups, yCG); /* for(int i = 0; i < nDown; i++){ printf("yCG[%i]=%i\n", i, yCG[i]); } */ double T[3][3]; for(int i = 0; i < numGroups; i++){ for(int j = 0; j < numGroups; j++){ T[i][j] = 0; } } // more efficient way of doing the below for(int j = 0; j < nDown-1; j++){ T[yCG[j]-1][yCG[j+1]-1] += 1; } /* for(int i = 0; i < numGroups; i++){ for(int j = 0; j < numGroups; j++){ printf("%1.f, ", T[i][j]); } printf("\n"); } */ /* for(int i = 0; i < numGroups; i++){ for(int j = 0; j < nDown-1; j++){ if(yCG[j] == i+1){ T[i][yCG[j+1]-1] += 1; } } } */ for(int i = 0; i < numGroups; i++){ for(int j = 0; j < numGroups; j++){ T[i][j] /= (nDown-1); // printf("T(%i, %i) = %1.3f\n", i, j, T[i][j]); } } double column1[3] = {0}; double column2[3] = {0}; double column3[3] = {0}; for(int i = 0; i < numGroups; i++){ column1[i] = T[i][0]; column2[i] = T[i][1]; column3[i] = T[i][2]; // printf("column3(%i) = %1.3f\n", i, column3[i]); } double *columns[3]; columns[0] = &(column1[0]); columns[1] = &(column2[0]); columns[2] = &(column3[0]); double COV[3][3]; double covTemp = 0; for(int i = 0; i < numGroups; i++){ for(int j = i; j < numGroups; j++){ covTemp = cov(columns[i], columns[j], 3); COV[i][j] = covTemp; COV[j][i] = covTemp; // printf("COV(%i , %i) = %1.3f\n", i, j, COV[i][j]); } } double sumdiagcov = 0; for(int i = 0; i < numGroups; i++){ sumdiagcov += COV[i][i]; } free(yFilt); free(yDown); free(yCG); return sumdiagcov; } ================================================ FILE: C/SB_TransitionMatrix.h ================================================ // // SB_TransitionMatrix.h // // // Created by Carl Henning Lubba on 23/09/2018. // #ifndef SB_TransitionMatrix_h #define SB_TransitionMatrix_h #include extern double SB_TransitionMatrix_3ac_sumdiagcov(const double y[], const int size); #endif /* SB_TransitionMatrix_h */ ================================================ FILE: C/SC_FluctAnal.c ================================================ #include #include #include #include #include #include "stats.h" #include "CO_AutoCorr.h" double SC_FluctAnal_2_50_1_logi_prop_r1(const double y[], const int size, const int lag, const char how[]) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } // generate log spaced tau vector double linLow = log(5); double linHigh = log(size/2); int nTauSteps = 50; double tauStep = (linHigh - linLow) / (nTauSteps-1); int tau[50]; for(int i = 0; i < nTauSteps; i++) { tau[i] = round(exp(linLow + i*tauStep)); } // check for uniqueness, use ascending order int nTau = nTauSteps; for(int i = 0; i < nTauSteps-1; i++) { while (tau[i] == tau[i+1] && i < nTau-1) { for(int j = i+1; j < nTauSteps-1; j++) { tau[j] = tau[j+1]; } // lost one nTau -= 1; } } // fewer than 12 points -> leave. if(nTau < 12){ return 0; } int sizeCS = size/lag; double * yCS = malloc(sizeCS * sizeof(double)); /* for(int i = 0; i < 50; i++) { printf("y[%i]=%1.3f\n", i, y[i]); } */ // transform input vector to cumsum yCS[0] = y[0]; for(int i = 0; i < sizeCS-1; i++) { yCS[i+1] = yCS[i] + y[(i+1)*lag]; /* if(i<300) printf("yCS[%i]=%1.3f\n", i, yCS[i]); */ } //for each value of tau, cut signal into snippets of length tau, detrend and // first generate a support for regression (detrending) double * xReg = malloc(tau[nTau-1] * sizeof * xReg); for(int i = 0; i < tau[nTau-1]; i++) { xReg[i] = i+1; } // iterate over taus, cut signal, detrend and save amplitude of remaining signal double * F = malloc(nTau * sizeof * F); for(int i = 0; i < nTau; i++) { int nBuffer = sizeCS/tau[i]; double * buffer = malloc(tau[i] * sizeof * buffer); double m = 0.0, b = 0.0; //printf("tau[%i]=%i\n", i, tau[i]); F[i] = 0; for(int j = 0; j < nBuffer; j++) { //printf("%i th buffer\n", j); linreg(tau[i], xReg, yCS+j*tau[i], &m, &b); for(int k = 0; k < tau[i]; k++) { buffer[k] = yCS[j*tau[i]+k] - (m * (k+1) + b); //printf("buffer[%i]=%1.3f\n", k, buffer[k]); } if (strcmp(how, "rsrangefit") == 0) { F[i] += pow(max_(buffer, tau[i]) - min_(buffer, tau[i]), 2); } else if (strcmp(how, "dfa") == 0) { for(int k = 0; k leave. if(nTau < 8){ return 0; } // transform input vector to cumsum for(int i = 0; i < size-1; i++) { y[i+1] = y[i] + y[i+1]; } //for each value of tau, cut signal into snippets of length tau, detrend and // first generate a support for regression (detrending) double * xReg = malloc(tau[nTau-1] * sizeof * xReg); for(int i = 0; i < tau[nTau-1]; i++) { xReg[i] = i+1; } // iterate over taus, cut signal, detrend and save amplitude of remaining signal double * F = malloc(nTau * sizeof * F); for(int i = 0; i < nTau; i++) { int nBuffer = size/tau[i]; double * buffer = malloc(tau[i] * sizeof * buffer); double m = 0.0, b = 0.0; F[i] = 0; for(int j = 0; j < nBuffer; j++) { linreg(tau[i], xReg, y+j*tau[i], &m, &b); for(int k = 0; k < tau[i]; k++) { buffer[k] = y[j*tau[i]+k] - (m * (k+1) + b); } F[i] += pow(max(buffer, tau[i]) - min(buffer, tau[i]), 2); } F[i] = sqrt(F[i]/nBuffer); free(buffer); } double * logtt = malloc(nTau * sizeof * logtt); double * logFF = malloc(nTau * sizeof * logFF); int ntt = nTau; for (int i = 0; i < nTau; i++) { logtt[i] = log(tau[i]); logFF[i] = log(F[i]); } int minPoints = 6; int nsserr = (ntt - 2*minPoints + 1); double * sserr = malloc(nsserr * sizeof * sserr); double * buffer = malloc((ntt - minPoints + 1) * sizeof * buffer); for (int i = minPoints; i < ntt - minPoints + 1; i++) { // this could be done with less variables of course double m1 = 0.0, b1 = 0.0; double m2 = 0.0, b2 = 0.0; sserr[i - minPoints] = 0.0; linreg(i, logtt, logFF, &m1, &b1); linreg(ntt-i+1, logtt+i-1, logFF+i-1, &m2, &b2); for(int j = 0; j < i; j ++) { buffer[j] = logtt[j] * m1 + b1 - logFF[j]; } sserr[i - minPoints] += norm(buffer, i); for(int j = 0; j < ntt-i+1; j++) { buffer[j] = logtt[j+i-1] * m2 + b2 - logFF[j+i-1]; } sserr[i - minPoints] += norm(buffer, ntt-i+1); } double firstMinInd = 0.0; double minimum = min(sserr, nsserr); for(int i = 0; i < nsserr; i++) { if(sserr[i] == minimum) { firstMinInd = i + minPoints - 1; break; } } free(xReg); free(F); free(logtt); free(logFF); free(sserr); free(buffer); return (firstMinInd+1)/ntt; } */ ================================================ FILE: C/SC_FluctAnal.h ================================================ #ifndef SC_FLUCTANAL #define SC_FLUCTANAL #include #include #include "stats.h" #include "CO_AutoCorr.h" extern double SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1(const double y[], const int size); extern double SC_FluctAnal_2_50_1_logi_prop_r1(const double y[], const int size, const char how[]); extern double SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1(const double y[], const int size); #endif ================================================ FILE: C/SP_Summaries.c ================================================ // // SP_Summaries.c // // // Created by Carl Henning Lubba on 23/09/2018. // #include "SP_Summaries.h" #include "CO_AutoCorr.h" int welch(const double y[], const int size, const int NFFT, const double Fs, const double window[], const int windowWidth, double ** Pxx, double ** f){ double dt = 1.0/Fs; double df = 1.0/(nextpow2(windowWidth))/dt; double m = mean(y, size); // number of windows, should be 1 int k = floor((double)size/((double)windowWidth/2.0))-1; // normalising scale factor double KMU = k * pow(norm_(window, windowWidth),2); double * P = malloc(NFFT * sizeof(double)); for(int i = 0; i < NFFT; i++){ P[i] = 0; } // fft variables cplx * F = malloc(NFFT * sizeof *F); cplx * tw = malloc(NFFT * sizeof *tw); twiddles(tw, NFFT); double * xw = malloc(windowWidth * sizeof(double)); for(int i = 0; i0 & i < Nout-1){ (*Pxx)[i] *= 2; } } /* for(int i = 0; i < Nout; i++){ printf("Pxx[%i]: %1.3f\n", i, Pxx[i]); } */ *f = malloc(Nout * sizeof(double)); for(int i = 0; i < Nout; i++){ (*f)[i] = (double)i*df; } /* for(int i = 0; i < Nout; i++){ printf("f[%i]: %1.3f\n", i, (*f)[i]); } */ free(P); free(F); free(tw); free(xw); return Nout; } double SP_Summaries_welch_rect(const double y[], const int size, const char what[]) { // NaN check for(int i = 0; i < size; i++) { if(isnan(y[i])) { return NAN; } } // rectangular window for Welch-spectrum double * window = malloc(size * sizeof(double)); for(int i = 0; i < size; i++){ window[i] = 1; } double Fs = 1.0; // sampling frequency int N = nextpow2(size); double * S; double * f; // compute Welch-power int nWelch = welch(y, size, N, Fs, window, size, &S, &f); free(window); // angualr frequency and spectrum on that double * w = malloc(nWelch * sizeof(double)); double * Sw = malloc(nWelch * sizeof(double)); double PI = 3.14159265359; for(int i = 0; i < nWelch; i++){ w[i] = 2*PI*f[i]; Sw[i] = S[i]/(2*PI); //printf("w[%i]=%1.3f, Sw[%i]=%1.3f\n", i, w[i], i, Sw[i]); if(isinf(Sw[i]) | isinf(-Sw[i])){ return 0; } } double dw = w[1] - w[0]; double * csS = malloc(nWelch * sizeof(double)); cumsum(Sw, nWelch, csS); /* for(int i=0; i csSThres){ centroid = w[i]; break; } } output = centroid; } else if(strcmp(what, "area_5_1") == 0){ double area_5_1 = 0;; for(int i=0; i extern double SP_Summaries_welch_rect(const double y[], const int size, const char what[]); extern double SP_Summaries_welch_rect_area_5_1(const double y[], const int size); extern double SP_Summaries_welch_rect_centroid(const double y[], const int size); #endif /* SP_Summaries_h */ ================================================ FILE: C/butterworth.c ================================================ // // butterworth.c // // // Created by Carl Henning Lubba on 23/09/2018. // #include #include #if __cplusplus # include typedef std::complex< double > cplx; #else # include #if defined(__GNUC__) || defined(__GNUG__) typedef double complex cplx; #elif defined(_MSC_VER) typedef _Dcomplex cplx; #endif #endif #include "helper_functions.h" #include "butterworth.h" #ifndef CMPLX #define CMPLX(x, y) ((cplx)((double)(x) + _Imaginary_I * (double)(y))) #endif void poly(cplx x[], int size, cplx out[]) { /* Convert roots x to polynomial coefficients */ // initialise #if defined(__GNUC__) || defined(__GNUG__) out[0] = 1; for(int i=1; i= 0) { out[i] += b[j]*(y[i-j]-offset); out[i] -= a[j]*out[i-j]; } else{ out[i] += 0; //b[j]*offset; // 'padding' out[i] -= 0; //a[j]*offset; } } } for(int i = 0; i < size; i++){ out[i] += offset; } } void reverse_array(double a[], int size){ /* Reverse the order of the elements in an array. Write back into the input array.*/ double temp; for(int i = 0; i < size/2; i++){ temp = a[i]; a[i] = a[size-i-1]; a[size-1-i] = temp; /* printf("indFrom = %i, indTo = %i\n", i, size-1-i); for(int i=0; i < size; i++){ printf("reversed[%i]=%1.3f\n", i, a[i]); } */ } } void filt_reverse(double y[], int size, double a[], double b[], int nCoeffs, double out[]){ /* Filter a signal y with the filter coefficients a and b _in reverse order_, output to array out.*/ double * yTemp = malloc(size * sizeof(double)); for(int i = 0; i < size; i++){ yTemp[i] = y[i]; } /* for(int i=0; i < size; i++){ printf("yTemp[%i]=%1.3f\n", i, yTemp[i]); } */ reverse_array(yTemp, size); /* for(int i=0; i < size; i++){ printf("reversed[%i]=%1.3f\n", i, yTemp[i]); } */ double offset = yTemp[0]; for(int i = 0; i < size; i++){ out[i] = 0; for(int j = 0; j < nCoeffs; j++){ if(i - j >= 0) { out[i] += b[j]*(yTemp[i-j]-offset); out[i] -= a[j]*out[i-j]; } else{ out[i] += 0; //b[j]*offset; // 'padding' out[i] -= 0; //a[j]*offset; } } } for(int i = 0; i < size; i++){ out[i] += offset; } reverse_array(out, size); free(yTemp); } /* void butterworthFilter(const double y[], int size, const int nPoles, const double W, double out[]){ double PI = 3.14159265359; double V = tan(W * PI/2); cplx * Q = malloc(nPoles * sizeof(cplx)); for(int i = 0; i 0){ // prod1mSp *= (1 - Sp[i]); //} } double G = creal(Sg / prod1mSp); cplx * Zpoly = malloc((nPoles+1) * sizeof(cplx)); cplx * Ppoly = malloc((nPoles+1) * sizeof(cplx)); // polynomial coefficients from poles and zeros for filtering poly(Z, nPoles, Zpoly); //for(int i = 0; i < nPoles+1; i++){ // printf("Zpoly[%i]= %1.3f + %1.3f i\n", i, creal(Zpoly[i]), cimag(Zpoly[i])); //} poly(P, nPoles, Ppoly); //for(int i = 0; i < nPoles+1; i++){ // printf("Ppoly[%i]= %1.3f + %1.3f i\n", i, creal(Ppoly[i]), cimag(Ppoly[i])); //} // coeffs for filtering double * b = malloc((nPoles+1) * sizeof(double)); // zeros double * a = malloc((nPoles+1) * sizeof(double)); // poles for(int i = 0; i extern void butterworthFilter(const double y[], const int size, const int nPoles, const double W, double out[]); #endif /* butterworth_h */ ================================================ FILE: C/fft.c ================================================ #include #include #include #if __cplusplus # include typedef std::complex< double > cplx; #else # include #if defined(__GNUC__) || defined(__GNUG__) typedef double complex cplx; #elif defined(_MSC_VER) typedef _Dcomplex cplx; #endif #endif #ifndef CMPLX #define CMPLX(x, y) ((cplx)((double)(x) + _Imaginary_I * (double)(y))) #endif #include "helper_functions.h" void twiddles(cplx a[], int size) { double PI = 3.14159265359; for (int i = 0; i < size; i++) { // cplx tmp = { 0, -PI * i / size }; #if defined(__GNUC__) || defined(__GNUG__) cplx tmp = 0.0 - PI * i / size * I; #elif defined(_MSC_VER) cplx tmp = {0.0, -PI * i / size }; #endif a[i] = cexp(tmp); //a[i] = cexp(-I * M_PI * i / size); } } static void _fft(cplx a[], cplx out[], int size, int step, cplx tw[]) { if (step < size) { _fft(out, a, size, step * 2, tw); _fft(out + step, a + step, size, step * 2, tw); for (int i = 0; i < size; i += 2 * step) { //cplx t = tw[i] * out[i + step]; cplx t = _Cmulcc(tw[i], out[i + step]); a[i / 2] = _Caddcc(out[i], t); a[(i + size) / 2] = _Cminuscc(out[i], t); } } } void fft(cplx a[], int size, cplx tw[]) { cplx * out = malloc(size * sizeof(cplx)); memcpy(out, a, size * sizeof(cplx)); _fft(a, out, size, 1, tw); free(out); } ================================================ FILE: C/fft.h ================================================ #ifndef FFT_H #define FFT_H //#include #if __cplusplus # include typedef std::complex< double > cplx; #else # include #if defined(__GNUC__) || defined(__GNUG__) typedef double complex cplx; #elif defined(_MSC_VER) typedef _Dcomplex cplx; #endif #endif #include #include #ifndef CMPLX #define CMPLX(x, y) ((cplx)((double)(x) + _Complex_I * (double)(y))) #endif extern void twiddles(cplx a[], int size); // extern void _fft(cplx a[], cplx out[], int size, int step, cplx tw[]); extern void fft(cplx a[], int size, cplx tw[]); extern void ifft(cplx a[], int size, cplx tw[]); #endif ================================================ FILE: C/helper_functions.c ================================================ #if __cplusplus # include typedef std::complex< double > cplx; #else # include #if defined(__GNUC__) || defined(__GNUG__) typedef double complex cplx; #elif defined(_MSC_VER) typedef _Dcomplex cplx; #endif #endif #include #include #include #include #include "stats.h" // compare function for qsort, for array of doubles static int compare (const void * a, const void * b) { if (*(double*)a < *(double*)b) { return -1; } else if (*(double*)a > *(double*)b) { return 1; } else { return 0; } } // wrapper for qsort for array of doubles. Sorts in-place void sort(double y[], int size) { qsort(y, size, sizeof(*y), compare); } // linearly spaced vector void linspace(double start, double end, int num_groups, double out[]) { double step_size = (end - start) / (num_groups - 1); for (int i = 0; i < num_groups; i++) { out[i] = start; start += step_size; } return; } double quantile(const double y[], const int size, const double quant) { double quant_idx, q, value; int idx_left, idx_right; double * tmp = malloc(size * sizeof(*y)); memcpy(tmp, y, size * sizeof(*y)); sort(tmp, size); /* for(int i=0; i < size; i++){ printf("y[%i]=%1.4f\n", i, y[i]); } for(int i=0; i < size; i++){ printf("sorted[%i]=%1.4f\n", i, tmp[i]); } */ // out of range limit? q = 0.5 / size; if (quant < q) { value = tmp[0]; // min value free(tmp); return value; } else if (quant > (1 - q)) { value = tmp[size - 1]; // max value free(tmp); return value; } quant_idx = size * quant - 0.5; idx_left = (int)floor(quant_idx); idx_right = (int)ceil(quant_idx); value = tmp[idx_left] + (quant_idx - idx_left) * (tmp[idx_right] - tmp[idx_left]) / (idx_right - idx_left); free(tmp); return value; } void binarize(const double a[], const int size, int b[], const char how[]) { double m = 0.0; if (strcmp(how, "mean") == 0) { m = mean(a, size); } else if (strcmp(how, "median") == 0) { m = median(a, size); } for (int i = 0; i < size; i++) { b[i] = (a[i] > m) ? 1 : 0; } return; } double f_entropy(const double a[], const int size) { double f = 0.0; for (int i = 0; i < size; i++) { if (a[i] > 0) { f += a[i] * log(a[i]); } } return -1 * f; } void subset(const int a[], int b[], const int start, const int end) { int j = 0; for (int i = start; i < end; i++) { b[j++] = a[i]; } return; } #if defined(__GNUC__) || defined(__GNUG__) cplx _Cmulcc(const cplx x, const cplx y) { /*double a = x._Val[0]; double b = x._Val[1]; double c = y._Val[0]; double d = y._Val[1]; cplx result = { (a * c - b * d), (a * d + c * b) }; */ return x*y; } cplx _Cminuscc(const cplx x, const cplx y) { //cplx result = { x._Val[0] - y._Val[0], x._Val[1] - y._Val[1] }; return x - y; } cplx _Caddcc(const cplx x, const cplx y) { // cplx result = { x._Val[0] + y._Val[0], x._Val[1] + y._Val[1] }; return x + y; } cplx _Cdivcc(const cplx x, const cplx y) { double a = creal(x); double b = cimag(x); double c = creal(y); double d = cimag(y); cplx result = (a*c + b*d) / (c*c + d*d) + (b*c - a*d)/(c*c + d*d) * I; return result; // return x / y; } #elif defined(_MSC_VER) cplx _Cminuscc(const cplx x, const cplx y) { cplx result = { x._Val[0] - y._Val[0], x._Val[1] - y._Val[1] }; return result; } cplx _Caddcc(const cplx x, const cplx y) { cplx result = { x._Val[0] + y._Val[0], x._Val[1] + y._Val[1] }; return result; } cplx _Cdivcc(const cplx x, const cplx y) { double a = x._Val[0]; double b = x._Val[1]; double c = y._Val[0]; double d = y._Val[1]; cplx result = { (a*c + b*d) / (c*c + d*d), (b*c - a*d)/(c*c + d*d)}; return result; } #endif ================================================ FILE: C/helper_functions.h ================================================ #ifndef HELPER_FUNCTIONS_H #define HELPER_FUNCTIONS_H #include #include #include #include "stats.h" #if __cplusplus # include typedef std::complex< double > cplx; #else # include #if defined(__GNUC__) || defined(__GNUG__) typedef double complex cplx; #elif defined(_MSC_VER) typedef _Dcomplex cplx; #endif #endif extern void linspace(double start, double end, int num_groups, double out[]); extern double quantile(const double y[], const int size, const double quant); extern void sort(double y[], int size); extern void binarize(const double a[], const int size, int b[], const char how[]); extern double f_entropy(const double a[], const int size); extern void subset(const int a[], int b[], const int start, const int end); extern cplx _Cminuscc(const cplx x, const cplx y); extern cplx _Caddcc(const cplx x, const cplx y); extern cplx _Cdivcc(const cplx x, const cplx y); #if defined(__GNUC__) || defined(__GNUG__) extern cplx _Cmulcc(const cplx x, const cplx y); #endif #endif ================================================ FILE: C/histcounts.c ================================================ // // histcounts.c // C_polished // // Created by Carl Henning Lubba on 19/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #include #include #include "stats.h" #include "histcounts.h" int num_bins_auto(const double y[], const int size){ double maxVal = max_(y, size); double minVal = min_(y, size); if (stddev(y, size) < 0.001){ return 0; } return ceil((maxVal-minVal)/(3.5*stddev(y, size)/pow(size, 1/3.))); } int histcounts_preallocated(const double y[], const int size, int nBins, int * binCounts, double * binEdges) { int i = 0; // check min and max of input array double minVal = DBL_MAX, maxVal=-DBL_MAX; for(int i = 0; i < size; i++) { // printf("histcountInput %i: %1.3f\n", i, y[i]); if (y[i] < minVal) { minVal = y[i]; } if (y[i] > maxVal) { maxVal = y[i]; } } // and derive bin width from it double binStep = (maxVal - minVal)/nBins; // variable to store counted occurances in for(i = 0; i < nBins; i++) { binCounts[i] = 0; } for(i = 0; i < size; i++) { int binInd = (y[i]-minVal)/binStep; if(binInd < 0) binInd = 0; if(binInd >= nBins) binInd = nBins-1; //printf("histcounts, i=%i, binInd=%i, nBins=%i\n", i, binInd, nBins); binCounts[binInd] += 1; } for(i = 0; i < nBins+1; i++) { binEdges[i] = i * binStep + minVal; } /* // debug for(i=0;i maxVal) { maxVal = y[i]; } } // if no number of bins given, choose spaces automatically if (nBins <= 0){ nBins = ceil((maxVal-minVal)/(3.5*stddev(y, size)/pow(size, 1/3.))); } // and derive bin width from it double binStep = (maxVal - minVal)/nBins; // variable to store counted occurances in *binCounts = malloc(nBins * sizeof(int)); for(i = 0; i < nBins; i++) { (*binCounts)[i] = 0; } for(i = 0; i < size; i++) { int binInd = (y[i]-minVal)/binStep; if(binInd < 0) binInd = 0; if(binInd >= nBins) binInd = nBins-1; (*binCounts)[binInd] += 1; } *binEdges = malloc((nBins+1) * sizeof(double)); for(i = 0; i < nBins+1; i++) { (*binEdges)[i] = i * binStep + minVal; } /* // debug for(i=0;i 0 binIdentity[i] = 0; // go through bin edges for(int j = 0; j < nEdges; j++){ if(y[i] < binEdges[j]){ binIdentity[i] = j; break; } } } return binIdentity; } int * histcount_edges(const double y[], const int size, const double binEdges[], const int nEdges) { int * histcounts = malloc(nEdges * sizeof(int)); for(int i = 0; i < nEdges; i++){ histcounts[i] = 0; } for(int i = 0; i < size; i++) { // go through bin edges for(int j = 0; j < nEdges; j++){ if(y[i] <= binEdges[j]){ histcounts[j] += 1; break; } } } return histcounts; } ================================================ FILE: C/histcounts.h ================================================ // // histcounts.h // C_polished // // Created by Carl Henning Lubba on 19/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #ifndef histcounts_h #define histcounts_h #include #include #include extern int num_bins_auto(const double y[], const int size); extern int histcounts(const double y[], const int size, int nBins, int ** binCounts, double ** binEdges); extern int histcounts_preallocated(const double y[], const int size, int nBins, int * binCounts, double * binEdges); extern int * histcount_edges(const double y[], const int size, const double binEdges[], const int nEdges); extern int * histbinassign(const double y[], const int size, const double binEdges[], const int nEdges); #endif /* histcounts_h */ ================================================ FILE: C/main.c ================================================ /* Include files */ #include "main.h" #include #include #include #include //#include #include "DN_HistogramMode_5.h" #include "DN_HistogramMode_10.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "CO_AutoCorr.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "SB_BinaryStats.h" #include "SB_MotifThree.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "SB_TransitionMatrix.h" #include "PD_PeriodicityWang.h" #include "stats.h" // check if data qualifies to be caught22 int quality_check(const double y[], const int size) { int minSize = 10; if(size < minSize) { return 1; } for(int i = 0; i < size; i++) { double val = y[i]; if(val == INFINITY || -val == INFINITY) { return 2; } if(isnan(val)) { return 3; } } return 0; } void run_features(double y[], int size, FILE * outfile, bool catch24) { int quality = quality_check(y, size); if(quality != 0) { fprintf(stdout, "Time series quality test not passed (code %i).\n", quality); return; } double * y_zscored = malloc(size * sizeof * y_zscored); // variables to keep time clock_t begin; double timeTaken; // output double result; // z-score first for all. zscore_norm2(y, size, y_zscored); // GOOD begin = clock(); result = DN_OutlierInclude_n_001_mdrmd(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "DN_OutlierInclude_n_001_mdrmd", timeTaken); // GOOD begin = clock(); result = DN_OutlierInclude_p_001_mdrmd(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "DN_OutlierInclude_p_001_mdrmd", timeTaken); // GOOD begin = clock(); result = DN_HistogramMode_5(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "DN_HistogramMode_5", timeTaken); // GOOD begin = clock(); result = DN_HistogramMode_10(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "DN_HistogramMode_10", timeTaken); //GOOD begin = clock(); result = CO_Embed2_Dist_tau_d_expfit_meandiff(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "CO_Embed2_Dist_tau_d_expfit_meandiff", timeTaken); //GOOD (memory leak?) begin = clock(); result = CO_f1ecac(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "CO_f1ecac", timeTaken); //GOOD begin = clock(); result = CO_FirstMin_ac(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "CO_FirstMin_ac", timeTaken); // GOOD (memory leak?) begin = clock(); result = CO_HistogramAMI_even_2_5(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "CO_HistogramAMI_even_2_5", timeTaken); // GOOD begin = clock(); result = CO_trev_1_num(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "CO_trev_1_num", timeTaken); //GOOD begin = clock(); result = FC_LocalSimple_mean1_tauresrat(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "FC_LocalSimple_mean1_tauresrat", timeTaken); //GOOD begin = clock(); result = FC_LocalSimple_mean3_stderr(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "FC_LocalSimple_mean3_stderr", timeTaken); //GOOD (memory leak?) begin = clock(); result = IN_AutoMutualInfoStats_40_gaussian_fmmi(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "IN_AutoMutualInfoStats_40_gaussian_fmmi", timeTaken); //GOOD begin = clock(); result = MD_hrv_classic_pnn40(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "MD_hrv_classic_pnn40", timeTaken); //GOOD begin = clock(); result = SB_BinaryStats_diff_longstretch0(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "SB_BinaryStats_diff_longstretch0", timeTaken); //GOOD begin = clock(); result = SB_BinaryStats_mean_longstretch1(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "SB_BinaryStats_mean_longstretch1", timeTaken); //GOOD (memory leak?) begin = clock(); result = SB_MotifThree_quantile_hh(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "SB_MotifThree_quantile_hh", timeTaken); //GOOD (memory leak?) begin = clock(); result = SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1", timeTaken); //GOOD begin = clock(); result = SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1", timeTaken); //GOOD begin = clock(); result = SP_Summaries_welch_rect_area_5_1(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "SP_Summaries_welch_rect_area_5_1", timeTaken); //GOOD begin = clock(); result = SP_Summaries_welch_rect_centroid(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "SP_Summaries_welch_rect_centroid", timeTaken); //OK, BUT filt in Butterworth sometimes diverges, now removed alltogether, let's see results. begin = clock(); result = SB_TransitionMatrix_3ac_sumdiagcov(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "SB_TransitionMatrix_3ac_sumdiagcov", timeTaken); // GOOD begin = clock(); result = PD_PeriodicityWang_th0_01(y_zscored, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "PD_PeriodicityWang_th0_01", timeTaken); if (catch24) { // GOOD begin = clock(); result = DN_Mean(y, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "DN_Mean", timeTaken); // GOOD begin = clock(); result = DN_Spread_Std(y, size); timeTaken = (double)(clock()-begin)*1000/CLOCKS_PER_SEC; fprintf(outfile, "%.14f, %s, %f\n", result, "DN_Spread_Std", timeTaken); } else { } fprintf(outfile, "\n"); free(y_zscored); } void print_help(char *argv[], char msg[]) { if (strlen(msg) > 0) { fprintf(stdout, "ERROR: %s\n", msg); } fprintf(stdout, "Usage is %s \n", argv[0]); fprintf(stdout, "\n\tSpecifying outfile is optional, by default it is stdout\n"); // fprintf(stdout, "\tOutput order is:\n%s\n", HEADER); exit(1); } // memory leak check; use with valgrind. #if 0 int main(int argc, char * argv[]) { double * y = malloc(1000 * sizeof(double)); srand(42); for (int i = 0; i < 1000; ++i) { y[i] = rand() % RAND_MAX; } run_features(y, 1000, stdout); free(y); } #endif #if 1 int main(int argc, char * argv[]) { FILE * infile, * outfile; int array_size; double * y; int size; double value; // DIR *d; struct dirent *dir; switch (argc) { case 1: print_help(argv, ""); break; case 2: if ((infile = fopen(argv[1], "r")) == NULL) { print_help(argv, "Can't open input file\n"); } outfile = stdout; break; case 3: if ((infile = fopen(argv[1], "r")) == NULL) { print_help(argv, "Can't open input file\n"); } if ((outfile = fopen(argv[2], "w")) == NULL) { print_help(argv, "Can't open output file\n"); } break; } /* // debug: fix these. infile = fopen("/Users/carl/PycharmProjects/catch22/C/timeSeries/tsid0244.txt", "r"); outfile = stdout; */ // fprintf(outfile, "%s", HEADER); array_size = 50; size = 0; y = malloc(array_size * sizeof *y); while (fscanf(infile, "%lf", &value) != EOF) { if (size == array_size) { y = realloc(y, 2 * array_size * sizeof *y); array_size *= 2; } y[size++] = value; } fclose(infile); y = realloc(y, size * sizeof *y); //printf("size=%i\n", size); // catch24 specification int catch24; printf("Do you want to run catch24? Enter 0 for catch22 or 1 for catch24."); scanf("%d", &catch24); if (catch24 == 1) { run_features(y, size, outfile, true); } else { run_features(y, size, outfile, false); } fclose(outfile); free(y); return 0; } #endif #if 0 int main(int argc, char * argv[]) { (void)argc; (void)argv; /* // generate some data const int size = 31; // 211; double y[size]; int i; double sinIn=0; for(i=0; i #include #include #include /* Function Declarations */ //extern int main(int argc, const char * const argv[]); extern int main(int argc, char * argv[]); #endif /* End of code generation (main.h) */ ================================================ FILE: C/runAllTS.sh ================================================ #!/bin/bash help() { echo "" echo "Usage: $0 -i indir -o outdir -a append_string -s" echo -e "\t-h Show this help message" echo -e "\t-i Path to a directory containing input time-series files (.txt with one time series value per line). Default: './timeSeries'" echo -e "\t-o Path to a directory in which to save output feature values. Default: './featureOutput'" echo -e "\t-a A string (minus extension) appended to the input file names to create the output file names. Default: 'output'" echo -e "\t-s A switch to evaluate catch22 (0) or catch24 (1). Default: 0" exit 1 } while getopts "i:o:a:s:h" opt do case "$opt" in i) indir="$OPTARG" ;; o) outdir="$OPTARG" ;; a) append="$OPTARG" ;; s) catch24="$OPTARG" ;; h) help ;; esac done srcdir=$(dirname "$0}") if [ -z "$indir" ] then indir="./timeSeries" fi if [ -z "$outdir" ] then outdir="./featureOutput" fi if [ -z "$append" ] then append="output" fi if [ -z "$catch24" ] then catch24=0 fi indir="$(dirname $indir)/$(basename $indir)" outdir="$(dirname $outdir)/$(basename $outdir)" mkdir -p $outdir # Loop through each file in indir and save the feature outputs for entry in "${indir}"/*.txt do filename=$(basename "$entry") extension="${filename##*.}" filename="${filename%.*}" fullfile="${outdir}/${filename}${append}.${extension}" if [ "${filename: -${#append}}" != "${append}" ] then yes $catch24 | "${srcdir}/run_features" $entry $fullfile > /dev/null if [ -s $fullfile ] # Remove file if catch22 errors then echo "Output written to ${fullfile}" else rm $fullfile fi fi done ================================================ FILE: C/splinefit.c ================================================ // Created by Carl Henning Lubba on 27/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // // Based on the work of Jonas Lundgren in his Matlab Central contribution 'SPLINEFIT'. // #include #include #include #include "splinefit.h" #include "stats.h" #define nCoeffs 3 #define nPoints 4 #define pieces 2 #define nBreaks 3 #define deg 3 #define nSpline 4 #define piecesExt 8 //3 * deg - 1 void matrix_multiply(const int sizeA1, const int sizeA2, const double *A, const int sizeB1, const int sizeB2, const double *B, double *C){ //void matrix_multiply(int sizeA1, int sizeA2, double **A, int sizeB1, int sizeB2, double **B, double C[sizeA1][sizeB2]){ if(sizeA2 != sizeB1){ return; } /* // show input for(int i = 0; i < sizeA1; i++){ for(int j = 0; j < sizeA2; j++){ printf("A[%i][%i] = %1.3f\n", i, j, A[i*sizeA2 + j]); } } */ for(int i = 0; i < sizeA1; i++){ for(int j = 0; j < sizeB2; j++){ //C[i][j] = 0; C[i*sizeB2 + j] = 0; for(int k = 0; k < sizeB1; k++){ // C[i][j] += A[i][k]*B[k][j]; C[i*sizeB2 + j] += A[i * sizeA2 + k]*B[k * sizeB2 + j]; //printf("C[%i][%i] (k=%i) = %1.3f\n", i, j, k, C[i * sizeB2 + j]); } } } } void matrix_times_vector(const int sizeA1, const int sizeA2, const double *A, const int sizeb, const double *b, double *c){ //c[sizeb] if(sizeA2 != sizeb){ return; } // row for(int i = 0; i < sizeA1; i++){ // column c[i] = 0; for(int k = 0; k < sizeb; k++){ c[i] += A[i * sizeA2 + k]*b[k]; } } } void gauss_elimination(int size, double *A, double *b, double *x){ // void gauss_elimination(int size, double A[size][size], double b[size], double x[size]){ double factor; // create temp matrix and vector // double *AElim[size]; double* AElim[nSpline + 1]; for (int i = 0; i < size; i++) AElim[i] = (double *)malloc(size * sizeof(double)); double * bElim = malloc(size * sizeof(double)); // -- create triangular matrix // initialise to A and b for(int i = 0; i < size; i++){ for(int j = 0; j < size; j++){ AElim[i][j] = A[i*size + j]; } bElim[i] = b[i]; } /* printf("AElim\n"); for(int i = 0; i < size; i++){ for(int j = 0; j < size; j++){ printf("%1.3f, ", AElim[i][j]); } printf("\n"); } */ // go through columns in outer loop for(int i = 0; i < size; i++){ // go through rows to eliminate for(int j = i+1; j < size; j++){ factor = AElim[j][i]/AElim[i][i]; // subtract in vector bElim[j] = bElim[j] - factor*bElim[i]; // go through entries of this row for(int k = i; k < size; k++){ AElim[j][k] = AElim[j][k] - factor*AElim[i][k]; } /* printf("AElim i=%i, j=%i\n", i, j); for(int i = 0; i < size; i++){ for(int j = 0; j < size; j++){ printf("%1.3f, ", AElim[i][j]); } printf("\n"); } */ } } /* for(int i = 0; i < size; i++){ for(int j = 0; j < size; j++){ printf("AElim[%i][%i] = %1.3f\n", i, j, AElim[i][j]); } } for(int i = 0; i < size; i++){ printf("bElim[%i] = %1.3f\n", i, bElim[i]); } */ // -- go backwards through triangular matrix and solve for x // row double bMinusATemp; for(int i = size-1; i >= 0; i--){ bMinusATemp = bElim[i]; for(int j = i+1; j < size; j++){ bMinusATemp -= x[j]*AElim[i][j]; } x[i] = bMinusATemp/AElim[i][i]; } /* for(int j = 0; j < size; j++){ printf("x[%i] = %1.3f\n", j, x[j]); } */ for (int i = 0; i < size; i++) free(AElim[i]); free(bElim); } void lsqsolve_sub(const int sizeA1, const int sizeA2, const double *A, const int sizeb, const double *b, double *x) //void lsqsolve_sub(int sizeA1, int sizeA2, double A[sizeA1][sizeA2], int sizeb, double b[sizeb], double x[sizeA1]) { // create temp matrix and vector /* double *AT[sizeA1*sizeA2]; for (int i = 0; i < sizeA2; i++) AT[i] = (double *)malloc(sizeA1 * sizeof(double)); double *ATA[sizeA2]; for (int i = 0; i < sizeA2; i++) ATA[i] = (double *)malloc(sizeA2 * sizeof(double)); double * ATb = malloc(sizeA1 * sizeof(double)); */ double * AT = malloc(sizeA2 * sizeA1 * sizeof(double)); double * ATA = malloc(sizeA2 * sizeA2 * sizeof(double)); double * ATb = malloc(sizeA2 * sizeof(double)); for(int i = 0; i < sizeA1; i++){ for(int j = 0; j < sizeA2; j++){ //AT[i,j] = A[j,i] AT[j * sizeA1 + i] = A[i * sizeA2 + j]; } } /* printf("\n b \n"); for(int i = 0; i < sizeA1; i++){ printf("%i, %1.3f\n", i, b[i]); } */ /* printf("\nA\n"); for(int i = 0; i < sizeA2; i++){ for(int j = 0; j < sizeA1; j++){ printf("%1.3f, ", AT[i * sizeA1 + j]); } printf("\n"); } */ matrix_multiply(sizeA2, sizeA1, AT, sizeA1, sizeA2, A, ATA); /* printf("ATA\n"); for(int i = 0; i < sizeA2; i++){ for(int j = 0; j < sizeA2; j++){ printf("%1.3f, ", ATA[i * sizeA2 + j]); } printf("\n"); } */ matrix_times_vector(sizeA2, sizeA1, AT, sizeA1, b, ATb); /* for(int i = 0; i < sizeA2; i++){ ATb[i] = 0; for(int j = 0; j < sizeA1; j++){ ATb[i] += AT[i*sizeA1 + j]*b[j]; //printf("%i, ATb[%i]=%1.3f, AT[i*sizeA1 + j]=%1.3f, b[j]=%1.3f\n", i, i, ATb[i], AT[i*sizeA1 + j],b[j]); } } */ /* for(int i = 0; i < nCoeffs; i++){ printf("b[%i] = %1.3f\n", i, b[i]); } */ /* for(int i = 0; i < sizeA2; i++){ printf("ATb[%i] = %1.3f\n", i, ATb[i]); } */ gauss_elimination(sizeA2, ATA, ATb, x); free(AT); free(ATA); free(ATb); } /* int lsqsolve() { //const int nPoints = 4; //const int nCoeffs = 3; //double A[nPoints][nCoeffs] = {}; double A[4][3]; A[0][0] = 1; A[1][0] = 3; A[2][0] = 6; A[3][0] = 8; A[0][1] = 4; A[1][1] = 5; A[2][1] = 3; A[3][1] = 12; A[0][2] = 4; A[1][2] = 1; A[2][2] = 0; A[3][2] = 7; //double b[nPoints] = {}; double b[4]; b[0] = 2; b[1] = 8; b[2] = 3; b[3] = 1; double x[4]; double * Alin = malloc(nPoints * nCoeffs * sizeof(double)); for(int i = 0; i < nPoints; i++){ for(int j = 0; j < nCoeffs; j++){ //AT[i,j] = A[j,i] Alin[i * nCoeffs + j] = A[i][j]; } } lsqsolve_sub(nPoints, nCoeffs, Alin, nPoints, b, x); free(Alin); return 0; } */ int iLimit(int x, int lim){ return x= breaks[breakInd] & breakInd= breaks[1]) breakInd = 1; A[(i%nSpline)+breakInd + (i/nSpline)*(nSpline+1)] = vB[i]; } /* printf("\nA:\n"); for(int i = 0; i < size; i++){ for(int j = 0; j < n+1; j++){ printf("%1.5f, ", A[i * (n+1) + j]); } printf("\n"); } */ double * x = malloc((nSpline+1)*sizeof(double)); // lsqsolve_sub(int sizeA1, int sizeA2, double *A, int sizeb, double *b, double *x) lsqsolve_sub(size, nSpline+1, A, size, y, x); /* printf("\nsolved x\n"); for(int i = 0; i < n+1; i++){ printf("%i, %1.4f\n", i, x[i]); } */ // coeffs of B-splines to combine by optimised weighting in x double C[pieces+nSpline-1][nSpline*pieces]; // initialise to 0 for(int i = 0; i < nSpline+1; i++){ for(int j = 0; j < nSpline*pieces; j++){ C[i][j] = 0; } } int CRow, CCol, coefRow, coefCol; for(int i = 0; i < nSpline*nSpline*pieces; i++){ CRow = i%nSpline + (i/nSpline)%2; CCol = i/nSpline; coefRow = i%(nSpline*2); coefCol =i/(nSpline*2); C[CRow][CCol] = coefsOut[coefRow][coefCol]; } /* printf("\nC:\n"); for(int i = 0; i < n+1; i++){ for(int j = 0; j < n*pieces; j++){ printf("%1.5f, ", C[i][j]); } printf("\n"); } */ // final coefficients double coefsSpline[pieces][nSpline]; for(int i = 0; i < pieces; i++){ for(int j = 0; j < nSpline; j++){ coefsSpline[i][j] = 0; } } //multiply with x for(int j = 0; j < nSpline*pieces; j++){ coefCol = j/pieces; coefRow = j%pieces; for(int i = 0; i < nSpline+1; i++){ coefsSpline[coefRow][coefCol] += C[i][j]*x[i]; } } /* printf("\ncoefsSpline:\n"); for(int i = 0; i < pieces; i++){ for(int j = 0; j < n; j++){ printf("%1.5f, ", coefsSpline[i][j]); } printf("\n"); } */ // compute piecewise polynomial int secondHalf = 0; for(int i = 0; i < size; i++){ secondHalf = i < breaks[1] ? 0 : 1; yOut[i] = coefsSpline[secondHalf][0]; } /* printf("\nvSpline first iter\n"); for(int i = 0; i < size; i++){ printf("%i, %1.5f\n", i, vSpline[i]); } */ for(int i = 1; i < nSpline; i ++){ for(int j = 0; j < size; j++){ secondHalf = j < breaks[1] ? 0 : 1; yOut[j] = yOut[j]*(j - breaks[1]*secondHalf) + coefsSpline[secondHalf][i]; } /* printf("\nvSpline %i th iter\n", i); for(int i = 0; i < size; i++){ printf("%i, %1.4f\n", i, vSpline[i]); } */ } /* printf("\nvSpline\n"); for(int i = 0; i < size; i++){ printf("%i, %1.4f\n", i, yOut[i]); } */ free(xsB); free(indexB); free(vB); free(A); free(x); return 0; } ================================================ FILE: C/splinefit.h ================================================ // // splinefit.h // C_polished // // Created by Carl Henning Lubba on 27/09/2018. // Copyright © 2018 Carl Henning Lubba. All rights reserved. // #ifndef splinefit_h #define splinefit_h #include extern int splinefit(const double *y, const int size, double *yOut); #endif /* splinefit_h */ ================================================ FILE: C/stats.c ================================================ #include #include #include #include #include "helper_functions.h" double min_(const double a[], const int size) { double m = a[0]; for (int i = 1; i < size; i++) { if (a[i] < m) { m = a[i]; } } return m; } double max_(const double a[], const int size) { double m = a[0]; for (int i = 1; i < size; i++) { if (a[i] > m) { m = a[i]; } } return m; } double mean(const double a[], const int size) { double m = 0.0; for (int i = 0; i < size; i++) { m += a[i]; } m /= size; return m; } double sum(const double a[], const int size) { double m = 0.0; for (int i = 0; i < size; i++) { m += a[i]; } return m; } void cumsum(const double a[], const int size, double b[]) { b[0] = a[0]; for (int i = 1; i < size; i++) { b[i] = a[i] + b[i-1]; //printf("b[%i]%1.3f = a[%i]%1.3f + b[%i-1]%1.3f\n", i, b[i], i, a[i], i, a[i-1]); } } void icumsum(const int a[], const int size, int b[]) { b[0] = a[0]; for (int i = 1; i < size; i++) { b[i] = a[i] + b[i-1]; //printf("b[%i]%1.3f = a[%i]%1.3f + b[%i-1]%1.3f\n", i, b[i], i, a[i], i, a[i-1]); } } double isum(const int a[], const int size) { double m = 0.0; for (int i = 0; i < size; i++) { m += a[i]; } return m; } double median(const double a[], const int size) { double m; double * b = malloc(size * sizeof *b); memcpy(b, a, size * sizeof *b); sort(b, size); if (size % 2 == 1) { m = b[size / 2]; } else { int m1 = size / 2; int m2 = m1 - 1; m = (b[m1] + b[m2]) / (double)2.0; } free(b); return m; } double stddev(const double a[], const int size) { double m = mean(a, size); double sd = 0.0; for (int i = 0; i < size; i++) { sd += pow(a[i] - m, 2); } sd = sqrt(sd / (size - 1)); return sd; } double cov(const double x[], const double y[], const int size){ double covariance = 0; double meanX = mean(x, size); double meanY = mean(y, size); for(int i = 0; i < size; i++){ // double xi =x[i]; // double yi =y[i]; covariance += (x[i] - meanX) * (y[i] - meanY); } return covariance/(size-1); } double cov_mean(const double x[], const double y[], const int size){ double covariance = 0; for(int i = 0; i < size; i++){ // double xi =x[i]; // double yi =y[i]; covariance += x[i] * y[i]; } return covariance/size; } double corr(const double x[], const double y[], const int size){ double nom = 0; double denomX = 0; double denomY = 0; double meanX = mean(x, size); double meanY = mean(y, size); for(int i = 0; i < size; i++){ nom += (x[i] - meanX) * (y[i] - meanY); denomX += (x[i] - meanX) * (x[i] - meanX); denomY += (y[i] - meanY) * (y[i] - meanY); //printf("x[%i]=%1.3f, y[%i]=%1.3f, nom[%i]=%1.3f, denomX[%i]=%1.3f, denomY[%i]=%1.3f\n", i, x[i], i, y[i], i, nom, i, denomX, i, denomY); } return nom/sqrt(denomX * denomY); } double autocorr_lag(const double x[], const int size, const int lag){ return corr(x, &(x[lag]), size-lag); } double autocov_lag(const double x[], const int size, const int lag){ return cov_mean(x, &(x[lag]), size-lag); } void zscore_norm(double a[], int size) { double m = mean(a, size); double sd = stddev(a, size); for (int i = 0; i < size; i++) { a[i] = (a[i] - m) / sd; } return; } void zscore_norm2(const double a[], const int size, double b[]) { double m = mean(a, size); double sd = stddev(a, size); for (int i = 0; i < size; i++) { b[i] = (a[i] - m) / sd; } return; } double moment(const double a[], const int size, const int start, const int end, const int r) { int win_size = end - start + 1; a += start; double m = mean(a, win_size); double mr = 0.0; for (int i = 0; i < win_size; i++) { mr += pow(a[i] - m, r); } mr /= win_size; mr /= stddev(a, win_size); //normalize return mr; } void diff(const double a[], const int size, double b[]) { for (int i = 1; i < size; i++) { b[i - 1] = a[i] - a[i - 1]; } } int linreg(const int n, const double x[], const double y[], double* m, double* b) //, double* r) { double sumx = 0.0; /* sum of x */ double sumx2 = 0.0; /* sum of x**2 */ double sumxy = 0.0; /* sum of x * y */ double sumy = 0.0; /* sum of y */ double sumy2 = 0.0; /* sum of y**2 */ /* for (int i = 0; i < n; i++) { fprintf(stdout, "x[%i] = %f, y[%i] = %f\n", i, x[i], i, y[i]); } */ for (int i=0;i #include #include extern double max_(const double a[], const int size); extern double min_(const double a[], const int size); extern double mean(const double a[], const int size); extern double sum(const double a[], const int size); extern void cumsum(const double a[], const int size, double b[]); extern void icumsum(const int a[], const int size, int b[]); extern double isum(const int a[], const int size); extern double median(const double a[], const int size); extern double stddev(const double a[], const int size); extern double corr(const double x[], const double y[], const int size); extern double cov(const double x[], const double y[], const int size); extern double cov_mean(const double x[], const double y[], const int size); extern double autocorr_lag(const double x[], const int size, const int lag); extern double autocov_lag(const double x[], const int size, const int lag); extern void zscore_norm(double a[], int size); extern void zscore_norm2(const double a[], const int size, double b[]); extern double moment(const double a[], const int size, const int start, const int end, const int r); extern void diff(const double a[], const int size, double b[]); extern int linreg(const int n, const double x[], const double y[], double* m, double* b); //, double* r); extern double norm_(const double a[], const int size); #endif ================================================ FILE: LICENSE ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: Matlab/BasisOperations/BF_Binarize.m ================================================ function yBin = BF_Binarize(y,binarizeHow) % BF_Binarize Converts an input vector into a binarized version % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ %------------------------------------------------------------------------------- % Check inputs, set defaults: %------------------------------------------------------------------------------- if nargin < 2 || isempty(binarizeHow) binarizeHow = 'diff'; end %------------------------------------------------------------------------------- % function to transform real values to 0 if <=0 and 1 if >0: %------------------------------------------------------------------------------- function Y = stepBinary(X) Y = zeros(size(X),'like',X); Y(X > 0) = 1; end %------------------------------------------------------------------------------- % Do the binary transformation: %------------------------------------------------------------------------------- switch binarizeHow case 'diff' % Binary signal: 1 for stepwise increases, 0 for stepwise decreases yBin = stepBinary(diff(y)); case 'mean' % Binary signal: 1 for above mean, 0 for below mean yBin = stepBinary(y - mean(y)); case 'median' % Binary signal: 1 for above median, 0 for below median yBin = stepBinary(y - median(y)); case 'iqr' % Binary signal: 1 if inside interquartile range, 0 otherwise iqr = quantile(y,[0.25, 0.75]); iniqr = (y > iqr(1) & y <= iqr(2)); yBin = zeros(length(y),1); yBin(iniqr) = 1; otherwise error('Unknown binary transformation setting ''%s''',binarizeHow) end end ================================================ FILE: Matlab/BasisOperations/CO_AutoCorr.m ================================================ function out = CO_AutoCorr(y,tau,whatMethod) % CO_AutoCorr Compute the autocorrelation of an input time series % %---INPUTS: % y, a scalar time series column vector. % % tau, the time-delay. If tau is a scalar, returns autocorrelation for y at that % lag. If tau is a vector, returns autocorrelations for y at that set of % lags. Can set tau empty, [], to return the full function for the % 'Fourier' estimation method. % % whatMethod, the method of computing the autocorrelation: 'Fourier', % 'TimeDomainStat', or 'TimeDomain'. % %---OUTPUT: the autocorrelation at the given time-lag. % %---NOTES: % Specifying whatMethod = 'TimeDomain' can tolerate NaN values in the time % series. % % Computing mean/std across the full time series makes a significant difference % for short time series, but can produce values outside [-1,+1]. The % filtering-based method used by Matlab's autocorr, is probably the best for % short time series, and is implemented here by specifying: whatMethod = % 'Fourier'. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % ------------------------------------------------------------------------------ % Check inputs: % ------------------------------------------------------------------------------ if nargin < 2 tau = 1; % Use a lag of 1 by default end if nargin < 3 || isempty(whatMethod) whatMethod = 'Fourier'; end % ------------------------------------------------------------------------------ % Evaluate the time-series autocorrelation % ------------------------------------------------------------------------------ switch whatMethod case 'Fourier' % ------------------------------------------------------------------------------ % Estimation based on Matlab function autocorr, based on method of: % [1] Box, G. E. P., G. M. Jenkins, and G. C. Reinsel. Time Series % Analysis: Forecasting and Control. 3rd edition. Upper Saddle River, % NJ: Prentice-Hall, 1994. nFFT = 2^(nextpow2(length(y))+1); F = fft(y-mean(y),nFFT); F = F.*conj(F); acf = ifft(F); acf = acf./acf(1); % Normalize acf = real(acf); acf = acf(1:length(y)); if isempty(tau) % return the full function out = acf; else % return a specific set of values out = zeros(length(tau),1); for i = 1:length(tau) if (tau(i) > length(acf)-1) || (tau(i) < 0) out(i) = NaN; else out(i) = acf(tau(i)+1); end end end end end ================================================ FILE: Matlab/BasisOperations/CO_FirstZero.m ================================================ function out = CO_FirstZero(y,corrFun,maxTau) % CO_FirstZero The first zero-crossing of a given autocorrelation function % %---INPUTS: % % y, the input time series % corrFun, the self-correlation function to measure: % (i) 'ac': normal linear autocorrelation function. Uses CO_AutoCorr to % calculate autocorrelations. % maxTau, a maximum time-delay to search up to. % % In future, could add an option to return the point at which the function % crosses the axis, rather than the first integer lag at which it has already % crossed (what is currently implemented). % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % ------------------------------------------------------------------------------ % Check inputs: % ------------------------------------------------------------------------------ N = length(y); % the length of the time series if nargin < 2 || isempty(corrFun) corrFun = 'ac'; % autocorrelation by default end if nargin < 3 || isempty(maxTau) maxTau = N; % search up to a maximum of the length of the time series % maxTau = 400; % searches up to this maximum time lag % maxTau = min(maxTau,N); % searched up to the length of the time series if this is less than maxTau end % ------------------------------------------------------------------------------ % Select the self-correlation function as an inline function % Eventually could add additional self-correlation functions switch corrFun case 'ac' % Autocorrelation at all time lags corrs = CO_AutoCorr(y,[],'Fourier'); corrs = corrs(2:end); % remove the zero-lag result otherwise error('Unknown correlation function ''%s''',corrFun); end % Calculate autocorrelation at increasing lags, until you find a negative one for tau = 1:maxTau-1 if corrs(tau) < 0 % we know it starts positive (1), so first negative will be the zero-crossing out = tau; return end end % If haven't left yet, set output to maxTau out = maxTau; % make sure this is a scalar output coder.varsize('out', [1, 1], [0 0]) end ================================================ FILE: Matlab/BasisOperations/CO_trev.m ================================================ function out = CO_trev(y, tau) % CO_trev Normalized nonlinear autocorrelation, trev function of a time series % % Calculates the trev function, a normalized nonlinear autocorrelation, % mentioned in the documentation of the TSTOOL nonlinear time-series analysis % package (available here: http://www.physik3.gwdg.de/tstool/). % % The quantity is often used as a nonlinearity statistic in surrogate data % analysis, cf. "Surrogate time series", T. Schreiber and A. Schmitz, Physica D, % 142(3-4) 346 (2000). % %---INPUTS: % % y, time series % % tau, time lag (can be 'ac' or 'mi' to set as the first zero-crossing of the % autocorrelation function, or the first minimum of the automutual % information function, respectively) % %---OUTPUTS: % the trev numerator and the denominator. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % ------------------------------------------------------------------------------ %% Set defaults: % ------------------------------------------------------------------------------ if nargin < 2 || isempty(tau) tau = 1; end % ------------------------------------------------------------------------------ % Compute trev quantities % ------------------------------------------------------------------------------ yn = y(1:end-tau); yn1 = y(1+tau:end); % yn, tau steps ahead % ------------------------------------------------------------------------------ % Fill output struct % ------------------------------------------------------------------------------ % % The numerator out.num = mean((yn1-yn).^3); % The denominator out.denom = (mean((yn1-yn).^2))^(3/2); end ================================================ FILE: Matlab/BasisOperations/DN_HistogramMode.m ================================================ function out = DN_HistogramMode(y,numBins) % DN_HistogramMode Mode of a data vector. % % Measures the mode of the data vector using histograms with a given number % of bins. % %---INPUTS: % % y, the input data vector % % numBins, the number of bins to use in the histogram. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ if nargin < 2 numBins = 'auto'; % ceil(sqrt(length(y))); end % Compute the histogram from the data: [N,binEdges] = histcounts_(y,numBins); % Compute bin centers from bin edges: binCenters = mean([binEdges(1:end-1); binEdges(2:end)]); % Mean position of maximums (if multiple): out = mean(binCenters(N == max(N))); end ================================================ FILE: Matlab/BasisOperations/DN_OutlierInclude_001_mdrmd.m ================================================ function out = DN_OutlierInclude_001_mdrmd(y,thresholdHow) % DN_OutlierInclude How statistics depend on distributional outliers. % % Measures a range of different statistics about the time series as more and % more outliers are included in the calculation according to a specified rule, % of outliers being furthest from the mean, greatest positive, or negative % deviations. % % The threshold for including time-series data points in the analysis increases % from zero to the maximum deviation, in increments of 0.01*sigma (by default), % where sigma is the standard deviation of the time series. % % At each threshold, the mean, standard error, proportion of time series points % included, median, and standard deviation are calculated, and outputs from the % algorithm measure how these statistical quantities change as more extreme % points are included in the calculation. % %---INPUTS: % y, the input time series (ideally z-scored) % % thresholdHow, the method of how to determine outliers: % (i) 'abs': outliers are furthest from the mean, % (ii) 'p': outliers are the greatest positive deviations from the mean, or % (iii) 'n': outliers are the greatest negative deviations from the mean. % % inc, the increment to move through (fraction of std if input time series is % z-scored) % % Most of the outputs measure either exponential, i.e., f(x) = Aexp(Bx)+C, or % linear, i.e., f(x) = Ax + B, fits to the sequence of statistics obtained in % this way. % % [future: could compare differences in outputs obtained with 'p', 'n', and % 'abs' -- could give an idea as to asymmetries/nonstationarities??] % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % ------------------------------------------------------------------------------ %% Check Inputs % ------------------------------------------------------------------------------ % If time series is all the same value -- ridiculous! ++BF 21/3/2010 if all(y == y(1)) % the whole time series is just a single value % fprintf(1,'The time series is a constant!\n'); out = NaN; return % this method is not suitable for such time series: return a NaN end N = length(y); % length of the time series inc = 0.01; % ------------------------------------------------------------------------------ %% Initialize thresholds % ------------------------------------------------------------------------------ switch thresholdHow case 'p' % analyze only positive deviations thr = (0:inc:max(y)); tot = sum(y >= 0); otherwise % case 'n' % analyze only negative deviations thr = (0:inc:max(-y)); tot = sum(y <= 0); end if isempty(thr) error('I suspect that this is a highly peculiar time series?!!!') end % msDt4 = zeros(length(thr),1); % median of index relative to middle % % for i = 1:length(thr) % th = thr(i); % the threshold % % % Construct a time series consisting of inter-event intervals for parts % % of the time serie exceeding the threshold, th % % if strcmp(thresholdHow,'n')% look at only positive deviations % r = find(y <= -th); % elseif strcmp(thresholdHow,'p')% look at only negative deviations % r = find(y >= th); % end % % msDt4 = median(r)/(N/2)-1; % % end msDt = zeros(length(thr),6); % mean, std, proportion_of_time_series_included, % median of index relative to middle, mean, % error for i = 1:length(thr) th = thr(i); % the threshold % Construct a time series consisting of inter-event intervals for parts % of the time serie exceeding the threshold, th if strcmp(thresholdHow,'n')% look at only positive deviations r = find(y <= -th); else % if strcmp(thresholdHow,'p')% look at only negative deviations r = find(y >= th); end Dt_exc = diff(r); % Delta t (interval) time series; exceeding threshold msDt(i,1) = mean(Dt_exc); % the mean value of this sequence msDt(i,3) = length(Dt_exc)/tot*100; % this is just really measuring the distribution % : the proportion of possible values % that are actually used in % calculation msDt(i,4) = median(r)/(N/2)-1; end % ------------------------------------------------------------------------------ %% Trim % ------------------------------------------------------------------------------ % Trim off where the number of events is only one; hence the differenced % series returns NaN %fbi = find(isnan(msDt(:,1)),1,'first'); % first bad index fbi = findFirstTrue(isnan(msDt(:,1))); if fbi ~= 0 msDt = msDt(1:fbi-1,:); thr = thr(1:fbi-1); end % Trim off where the statistic power is lacking: less than 2% of data % included trimthr = 2; % percent % mj = find(msDt(:,3) > trimthr,1,'last'); mj = findLastTrue(msDt(:,3) > trimthr); if mj ~= 0 msDt = msDt(1:mj,:); thr = thr(1:mj); end % ------------------------------------------------------------------------------ %%% Generate output: % ------------------------------------------------------------------------------ %% Stationarity assumption % mean, median and std of the median and mean of range indices % out.mdrm = mean(msDt(:,4)); % out.mdrmd = median(msDt(:,4)); % out.mdrstd = std(msDt(:,4)); % % out.mrm = mean(msDt(:,5)); % out.mrmd = median(msDt(:,5)); % out.mrstd = std(msDt(:,5)); % mdrmd out = median(msDt(:,4)); % median(msDt4(:)); end function out = findFirstTrue(y) out = 0; coder.varsize('out', [1 1], [0 0]); for i = 1:length(y) if y(i) out = i; return end end end function out = findLastTrue(y) out = 0; coder.varsize('out', [1 1], [0 0]); for i = length(y):-1:1 if y(i) out = i; return end end end ================================================ FILE: Matlab/BasisOperations/NK_hist2.m ================================================ function [MN, xedges, yedges] = NK_hist2(x, y, xedges, yedges) % function MN = NK_hist2(x, y, xedges, yedges) % % 2D histogram: Extract the number of joint events - (x,y) data value pairs % that fall in each bin of the grid defined by xedges and yedges. % % ==================================================================== % Uses: % [N,BIN] = histc(X,EDGES) % which returns % 1) N is a LENGTH(EDGES) vector, N(k) will count the value X(i) if EDGES(k) <= X(i) < EDGES(k+1). The % last bin will count any values of X that match EDGES(end). % 2) an index matrix BIN. % If X is a vector, N(K) = SUM(BIN==K). % BIN is zero for out of range values. % If X is an m-by-n matrix, then, for j=1:n, N(K,j) = SUM(BIN(:,j)==K); end % ==================================================================== % % Please, see the notes to histc too. % N.B. It is always a better idea to use the % HISTC mex (a much faster compiled C code) if you have it % Then just replace the histc with HISTC in all calls % contained in the NK_hist2() .m function % % (c) Nedialko Krouchev 2006, Universite de Montreal, GRSNC if nargin ~= 4 error('The four input arguments are required!'); end if any(size(x) ~= size(y)) error('The size of the two first input vectors should be same!'); end [xn, xbin] = histc(x,xedges); [yn, ybin] = histc(y,yedges); xnbin = length(xedges); ynbin = length(yedges); %% xbin, ybin are zero for out of range values kkL = find( xxedges(xnbin) ); if ~isempty( kkR ) xnbin = xnbin + 1; xedges(xnbin) = max(x); end xbin( kkR ) = xnbin; kkL = find( yyedges(ynbin) ); if ~isempty( kkR ) ynbin = ynbin + 1; yedges(ynbin) = max(y); end ybin( kkR ) = ynbin; xyBinEdges = 1:xnbin*ynbin; % ==================================================================== % A more Elegant end-spiel: % % If x belongs to jBin=xbin(x), and y belongs to iBin=ybin(y), % Then (x,y) pairs belong "columnwise" to: % ijBin = (jBin-1)*ynbin + iBin xyBin = (xbin-1)*ynbin + ybin; % ==================================================================== MN = histc(xyBin, xyBinEdges); MN = reshape(MN, ynbin, xnbin); end ================================================ FILE: Matlab/BasisOperations/SB_CoarseGrain_quantile.m ================================================ function yth = SB_CoarseGrain_quantile(y,numGroups) % SB_CoarseGrain Coarse-grains a continuous time series to a discrete alphabet. % %---INPUTS: % howtocg = 'quantile' puts an equal number into each bin, the method of coarse-graining % % numGroups, either specifies the size of the alphabet for 'quantile' and 'updown' % or sets the timedelay for the embedding subroutines % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ N = length(y); % length of the input sequence % ------------------------------------------------------------------------------ % Do the coarse graining % ------------------------------------------------------------------------------ % quantile th = quantile(y,linspace(0,1,numGroups+1)); % thresholds for dividing the time series values th(1) = th(1)-1; % this ensures the first point is included % turn the time series into a set of numbers from 1:numGroups yth = zeros(N,1); for i = 1:numGroups yth(y > th(i) & y <= th(i+1)) = i; end if any(yth == 0) error('All values in the sequence were not assigned to a group') end end ================================================ FILE: Matlab/BasisOperations/SB_TransitionMatrix.m ================================================ function out = SB_TransitionMatrix(y, numGroups, tauIn) % SB_TransitionMatrix Transition probabilities between different time-series states. % % The time series is coarse-grained according to a given method. % % The input time series is transformed into a symbolic string using an % equiprobable alphabet of numGroups letters. The transition probabilities are % calculated at a lag tau. % %---INPUTS: % y, the input time series % % % numGroups: number of groups in the course-graining % % tau: analyze transition matricies corresponding to this lag. We % could either downsample the time series at this lag and then do the % discretization as normal, or do the discretization and then just % look at this dicrete lag. Here we do the former. Can also set tau to 'ac' % to set tau to the first zero-crossing of the autocorrelation function. % %---OUTPUTS: include the transition probabilities themselves, as well as the trace % of the transition matrix, measures of asymmetry, and eigenvalues of the % transition matrix. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % % ------------------------------------------------------------------------------ % % Check inputs: % % ------------------------------------------------------------------------------ if nargin < 2 || isempty(numGroups) numGroups = 2; end if numGroups < 2 error('Too few groups for coarse-graining') end if nargin < 3 || isempty(tauIn) tau = 1; elseif strcmp(tauIn,'ac') % determine tau from first zero of autocorrelation tau = CO_FirstZero(y,'ac'); elseif ischar(tauIn) || isstring(tauIn) tau = str2double(tauIn); end if isnan(tau) error('Time series too short to estimate tau'); end if tau > 1 % calculate transition matrix at non-unity lag % downsample at rate 1:tau yDown = downsample(y,tau); % yDown = decimate_(y,tau); % yDown = resample(y,1,tau); else yDown = y; end N = length(yDown); % time-series length % ------------------------------------------------------------------------------ %% (((1))) Discretize the time series % ------------------------------------------------------------------------------ yth = SB_CoarseGrain_quantile(yDown,numGroups); % At this point we should have: % (*) yth: a thresholded y containing integers from 1 to numGroups % ------------------------------------------------------------------------------ %% (((2))) find 1-time transition matrix % ------------------------------------------------------------------------------ % Probably implemented already, but I'll do it myself T = zeros(numGroups); % probability of transition from state i -> state j for i = 1:numGroups ri = (yth == i); % indices where the time series is in state i if sum(ri)==0 % is never in state i T(i,:) = 0; % all transition probabilities are zero (could be NaN) else % Indices of states immediately following a state i: ri_next = [logical(0);ri(1:end-1)]; % Compute transitions from state i to each of the states j: for j = 1:numGroups T(i,j) = sum(yth(ri_next) == j); % the next element is of this class end end end % Normalize from counts to probabilities: T = T/(N-1); % N-1 is appropriate because it's a 1-time transition matrix % ------------------------------------------------------------------------------ %% (((3))) output measures from the transition matrix % ------------------------------------------------------------------------------ % % (i) Raw values of the transition matrix % % [this has to be done bulkily (only for numGroups = 2,3)]: % if numGroups == 2; % return all elements of T % for i = 1:4 % out.(sprintf('T%u',i)) = T(i); % end % elseif numGroups == 3; % return all elements of T % for i = 1:9 % out.(sprintf('T%u',i)) = T(i); % end % elseif numGroups > 3 % return just diagonal elements of T % for i = 1:numGroups % out.(sprintf('TD%u',i)) = T(i,i); % end % end % (ii) Measures on the diagonal out.ondiag = sum(diag(T)); % trace % out.stddiag = std(diag(T)); % std of diagonal elements % % % (iii) Measures of symmetry: % out.symdiff = sum(sum(abs((T-T')))); % sum of differences of individual elements % out.symsumdiff = sum(sum(tril(T,-1)))-sum(sum(triu(T,+1))); % difference in sums of upper and lower % triangular parts of T % (iv) Measures from covariance matrix: covT = cov(T); out.sumdiagcov = sum(diag(covT)); % trace of covariance matrix % % % (v) Measures from eigenvalues of T % % eigT = eig(T); % % out.stdeig = std(eigT); % std of eigenvalues % % out.maxeig = max(real(eigT)); % maximum eigenvalue % % out.mineig = min(real(eigT)); % minimum eigenvalue % % % mean eigenvalue is equivalent to trace % % % (ought to be always zero? Not necessary to measure:) % % out.maximeig = max(imag(eigT)); % maximum imaginary part of eigenavlues % % % % (vi) Eigenvalues of covariance matrix: % % (mean eigenvalue of covariance matrix equivalent to trace of covariance matrix). % % (these measures don't make much sense in the case of 2 groups): % eigcovT = eig(covT); % % out.stdeigcov = std(eigcovT); % std of eigenvalues of covariance matrix % out.maxeigcov = real(max(eigcovT)); % (made real for C-implementation) max eigenvalue of covariance matrix % % out.mineigcov = min(eigcovT); % min eigenvalue of covariance matrix end ================================================ FILE: Matlab/BasisOperations/SC_FluctAnal_q2_taustep50_k1_logi_prop_r1.m ================================================ function out = SC_FluctAnal_q2_taustep50_k1_logi_prop_r1(x,wtf,lag) % SC_FluctAnal Implements fluctuation analysis by a variety of methods. % % Much of our implementation is based on the well-explained discussion of % scaling methods in: % "Power spectrum and detrended fluctuation analysis: Application to daily % temperatures" P. Talkner and R. O. Weber, Phys. Rev. E 62(1) 150 (2000) % % The main difference between algorithms for estimating scaling exponents amount % to differences in how fluctuations, F, are quantified in time-series segments. % Many alternatives are implemented in this function. % %---INPUTS: % y, the input time series % % q=2, the parameter in the fluctuation function q = 2 (usual) gives RMS fluctuations. % % wtf, (what to fluctuate) % (i) 'dfa' removes a polynomial trend of order k in each segment, % % (ii) 'rsrangefit' fits a polynomial of order k and then returns the % range. The parameter q controls the order of fluctuations, for which % we mostly use the standard choice, q = 2, corresponding to root mean % square fluctuations. % An optional input parameter to this operation is a timelag for % computing the cumulative sum (or integrated profile), as suggested % by: "Using detrended fluctuation analysis for lagged correlation % analysis of nonstationary signals" J. Alvarez-Ramirez et al. Phys. % Rev. E 79(5) 057202 (2009) % % tauStep=50, increments in tau for linear range (i.e., if logInc = 0), or number of tau % steps in logarithmic range if login = 1 % The spacing of time scales, tau, is commonly logarithmic through a range from % 5 samples to a quarter of the length of the time series, as suggested in % "Statistical properties of DNA sequences", C.-K. Peng et al. Physica A % 221(1-3) 180 (1995) % % Max A. Little's fractal paper used L = 4 to L = N/2: % "Exploiting Nonlinear Recurrence and Fractal Scaling Properties for Voice Disorder Detection" % M. A. Little et al. Biomed. Eng. Online 6(1) 23 (2007) % % k=1, polynomial order of detrending for 'dfa', 'rsrangefit' % % lag, optional time-lag, as in Alvarez-Ramirez (see (vii) above) % % logInc=1, whether to use logarithmic increments in tau (it should be logarithmic). % %---OUTPUTS: include statistics of fitting a linear function to a plot of log(F) as % a function of log(tau), and for fitting two straight lines to the same data, % choosing the split point at tau = tau_{split} as that which minimizes the % combined fitting errors. % % This function can also be applied to the absolute deviations of the time % series from its mean, and also for just the sign of deviations from the mean % (i.e., converting the time series into a series of +1, when the time series is % above its mean, and -1 when the time series is below its mean). % % All results are obtained with both linearly, and logarithmically-spaced time % scales tau. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % ------------------------------------------------------------------------------ % Check Inputs: % ------------------------------------------------------------------------------ if nargin < 2 || isempty(wtf) wtf = 'rsrange'; % re-scaled range analysis by default end if nargin < 3 || isempty(lag) lag = ''; end q = 2; tauStep = 50; k = 1; % ------------------------------------------------------------------------------ % ------------------------------------------------------------------------------ N = length(x); % length of the time series doPlot = 0; % plot relevant outputs to figure % 1) Compute integrated sequence if isempty(lag) % didn't specify a lag, do a normal cumsum: y = cumsum(x); else % specified a lag, do a decimation: y = cumsum(x(1:lag:end)); end %------------------------------------------------------------------------------- % Perform scaling over a range of tau, up to a fifth the time-series length %------------------------------------------------------------------------------- % Peng (1995) suggests 5:N/4 for DFA % Caccia suggested from 10 to (N-1)/2... %------------------------------------------------------------------------------- taur = unique(round(exp(linspace(log(5),log(floor(N/2)),tauStep)))); ntau = length(taur); % analyze the time series across this many timescales if ntau < 8 % fewer than 8 points % fprintf(1,'This time series (N = %u) is too short to analyze using this fluctuation analysis\n',N); out = NaN; return end % 2) Compute the fluctuation function as follows F = zeros(1,ntau); % F is the fluctuation function % each entry correponds to a given scale tau, and contains % the fluctuation function at that scale for i = 1:ntau % buffer the time series at the scale tau tau = taur(i); % the scale on which to compute fluctuations % y_buff = buffer(y,tau); % buff not supported by Coder y_buff = buffer_(y,tau); if size(y_buff,2) > floor(length(y)/tau) % zero-padded, remove trailing set of points... y_buff = y_buff(:,1:end-1); end % analyzed length of time series (with trailing end-points removed) nn = size(y_buff,2)*tau; switch wtf case 'dfa' tt = (1:tau)'; % faux time range for j = 1:size(y_buff,2) % fit a polynomial of order k in each subsegment p = polyfit(tt,y_buff(:,j),k); % remove the trend, store back in y_buff y_buff(:,j) = y_buff(:,j) - polyval(p,tt); end % reshape to a column vector, y_dt (detrended) y_dt = reshape(y_buff,nn,1); case 'rsrangefit' % polynomial fit (order k) rather than endpoints fit: (~DFA) tt = (1:tau)'; % faux time range for j = 1:size(y_buff,2) % fit a polynomial of order k in each subsegment p = polyfit(tt,y_buff(:,j),k); % remove the trend, store back in y_buff y_buff(:,j) = y_buff(:,j) - polyval(p,tt); end y_dt = max(y_buff) - min(y_buff); % range(y_buff); otherwise error('Unknown fluctuation analysis method ''%s''',wtf); end % Compute fluctuation function: F(i) = (mean(y_dt.^q)).^(1/q); end %------------------------------------------------------------------------------- % Smooth unevenly-distributed points in log space: %------------------------------------------------------------------------------- logtt = log(taur); logFF = log(F); ntt = ntau; % ------------------------------------------------------------------------------ %% Try assuming two components (2 distinct scaling regimes) % ------------------------------------------------------------------------------ % Move through, and fit a straight line to loglog before and after each point. % Find point with the minimum sum of squared errors % First spline interpolate to get an even sampling of the interval % (currently, in the log scale, there are relatively more at large scales % Deterine the errors sserr = nan(ntt,1); % don't choose the end points minPoints = 6; for i = minPoints:ntt-minPoints r1 = 1:i; p1 = polyfit(logtt(r1),logFF(r1),1); r2 = i:ntt; p2 = polyfit(logtt(r2),logFF(r2),1); % Sum of errors from fitting lines to both segments: sserr(i) = norm(polyval(p1,logtt(r1))-logFF(r1)) + norm(polyval(p2,logtt(r2))-logFF(r2)); end % breakPt is the point where it's best to fit a line before and another line after breakPt = find(sserr == min(sserr),1,'first'); r1 = 1:breakPt; prop_r1 = length(r1)/ntt; % output out = prop_r1; end ================================================ FILE: Matlab/BasisOperations/SP_Summaries_welch_rect.m ================================================ function out = SP_Summaries_welch_rect(y) % SP_Summaries Statistics of the power spectrum of a time series % % The estimation can be done using a periodogram, using the periodogram code in % Matlab's Signal Processing Toolbox, or a fast fourier transform, implemented % using Matlab's fft code. % %---INPUTS: % y, the input time series % % psdMeth, the method of obtaining the spectrum from the signal: % (i) 'periodogram': periodogram % (ii) 'fft': fast fourier transform % (iii) 'welch': Welch's method % % windowType='rect', the window to use: % (i) 'boxcar' % (ii) 'rect' % (iii) 'bartlett' % (iv) 'hann' % (v) 'hamming' % (vi) 'none' % % nf, the number of frequency components to include, if % empty (default), it's approx length(y) % % dologabs, if 1, takes log amplitude of the signal before % transforming to the frequency domain. % % doPower, analyzes the power spectrum rather than amplitudes of a Fourier % transform % %---OUTPUTS: % Statistics summarizing various properties of the spectrum, % including its maximum, minimum, spread, correlation, centroid, area in certain % (normalized) frequency bands, moments of the spectrum, Shannon spectral % entropy, a spectral flatness measure, power-law fits, and the number of % crossings of the spectrum at various amplitude thresholds. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % % ------------------------------------------------------------------------------ % %% Check that a Curve-Fitting Toolbox license is available: % % ------------------------------------------------------------------------------ % BF_CheckToolbox('curve_fitting_toolbox') % ------------------------------------------------------------------------------ % Check inputs, set defaults: % ------------------------------------------------------------------------------ % if size(y,2) > size(y,1) % y = y'; % Time series must be a column vector % end % if nargin < 2 || isempty(psdMeth) % psdMeth = 'fft'; % fft by default % end % if nargin < 3 || isempty(windowType) % windowType = 'hamming'; % Hamming window by default % end % if nargin < 4 % nf = []; % end % if nargin < 5 || isempty(dologabs) % dologabs = false; % end % % if dologabs % a boolean % % Analyze the spectrum of logarithmic absolute deviations % y = log(abs(y)); % end doPlot = false; % plot outputs Ny = length(y); % time-series length % default output out.centroid = NaN; out.area_5_1 = NaN; %------------------------------------------------------------------------------- % Set window (for periodogram and welch): %------------------------------------------------------------------------------- window = ones(Ny,1); % rectwin(Ny); % ------------------------------------------------------------------------------ % Compute the Fourier Transform % ------------------------------------------------------------------------------ % Welch power spectral density estimate: Fs = 1; % sampling frequency N = 2^nextpow2(Ny); % [S, f] = pwelch(y,window,[],N,Fs); % substitute with own Welch spectrum [S_, f_] = welchy(y, N, Fs, window); w_ = 2*pi*f_'; % angular frequency S_ = S_/(2*pi); % adjust so that area remains normalized in angular frequency space if ~any(isfinite(S_)) % no finite values in the power spectrum % This time series must be really weird -- return NaN (unsuitable operation)... % warning('NaN in power spectrum? A weird time series.'); return end % Ensure both w and S are row vectors: if size(S_,1) > size(S_,2) S = S_'; else S = S_; end if size(w_,1) > size(w_,2) w = w_'; else w = w_; end % if doPlot % figure('color','w') % plot(w,S,'.-k'); % plot the spectrum % % Area under S should sum to 1 if a power spectral density estimate: % title(sprintf('Area under psd curve = %.1f (= %.1f)',sum(S*(w(2)-w(1))),var(y))); % end N = length(S); dw = w(2) - w(1); % spacing increment in w % ------------------------------------------------------------------------------ % Shape of cumulative sum curve % ------------------------------------------------------------------------------ csS = cumsum(S); % this original was not well received by coder. % f_frac_w_max = @(f) w(find(csS >= csS(end)*f,1,'first')); % At what frequency is csS a fraction 0.5 of its maximum? csSThres = csS(end)*0.5; for i = 1:length(csS) if csS(i) > csSThres out.centroid = w(i); break end end % % wInd = find((csS >= csS(end)*0.5),1, 'first'); % % out = w(wInd); % f_frac_w_max(0.5); % out = NaN; % 5 bands split = buffer_(S,floor(N/5)); if size(split,2) > 5, split = split(:,1:5); end out.area_5_1 = sum(split(:,1))*dw; end ================================================ FILE: Matlab/BasisOperations/buffer_.m ================================================ function y_buff = buffer_(y, tau) % replacement for y_buff = buffer(y,tau) nCols = ceil(length(y)/tau); yPadded = zeros(nCols*tau,1); yPadded(1:length(y)) = y; y_buff = reshape(yPadded, tau, nCols); ================================================ FILE: Matlab/BasisOperations/decimate_.m ================================================ function out = decimate_(y, q) nfilt = 4; nd = length(y); [b,a] = myButter(nfilt, 0.8/q); % be sure to filter in both directions to make sure the filtered data has zero phase % make a data vector properly pre- and ap- pended to filter forwards and back % so end effects can be obliterated. out_filt = filtfilt_(b,a,y); nbeg = 1; out = out_filt((nbeg:q:nd)'); ================================================ FILE: Matlab/BasisOperations/downsample_.m ================================================ %------------------------------------------------------------------------- function [y, h] = downsample_( x, q ) p = 1; bta = 5; N = 10; if (p==1) && (q==1) y = x; h = 1; return end pqmax = max(p,q); if length(N)>1 % use input filter L = length(N); h = N; else % design filter if( N>0 ) fc = 1/2/pqmax; L = 2*N*pqmax + 1; h = firls( L-1, [0 2*fc 2*fc 1], [1 1 0 0]).*kaiser(L,bta)' ; h = p*h/sum(h); else L = p; h = ones(1,p); end end Lhalf = (L-1)/2; isvect = any(size(x)==1); if isvect Lx = length(x); else Lx = size(x, 1); end % Need to delay output so that downsampling by q hits center tap of filter. nz = floor(q-mod(Lhalf,q)); z = zeros(1,nz); h = [z h(:).']; % ensure that h is a row vector. Lhalf = Lhalf + nz; % Number of samples removed from beginning of output sequence % to compensate for delay of linear phase filter: delay = floor(ceil(Lhalf)/q); % Need to zero-pad so output length is exactly ceil(Lx*p/q). nz1 = 0; while ceil( ((Lx-1)*p+length(h)+nz1 )/q ) - delay < ceil(Lx*p/q) nz1 = nz1+1; end h = [h zeros(1,nz1)]; % ---- HERE'S THE CALL TO UPFIRDN ---------------------------- y = upfirdn(x,h,p,q); % Get rid of trailing and leading data so input and output signals line up % temporally: Ly = ceil(Lx*p/q); % output length % Ly = floor((Lx-1)*p/q+1); <-- alternately, to prevent "running-off" the % data (extrapolation) if isvect y(1:delay) = []; y(Ly+1:end) = []; else y(1:delay,:) = []; y(Ly+1:end,:) = []; end h([1:nz (end-nz1+1):end]) = []; % get rid of leading and trailing zeros % in case filter is output ================================================ FILE: Matlab/BasisOperations/filtfilt_.m ================================================ function y = filtfilt_(b,a,x) %FILTFILT Zero-phase forward and reverse digital IIR filtering. % Y = FILTFILT(B, A, X) filters the data in vector X with the filter % described by vectors A and B to create the filtered data Y. The filter % is described by the difference equation: % % a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb) % - a(2)*y(n-1) - ... - a(na+1)*y(n-na) % % The length of the input X must be more than three times the filter % order, defined as max(length(B)-1,length(A)-1). % % References: % [1] Sanjit K. Mitra, Digital Signal Processing, 2nd ed., % McGraw-Hill, 2001 % [2] Fredrik Gustafsson, Determining the initial states in forward- % backward filtering, IEEE Transactions on Signal Processing, % pp. 988-992, April 1996, Volume 44, Issue 4 % Copyright 1988-2014 The MathWorks, Inc. %% Parse coefficient coefficients vectors and determine initial conditions na = numel(a); L = 1; % Check coefficients b = b(:); a = a(:); nb = numel(b); nfilt = max(nb,na); nfact = max(1,3*(nfilt-1)); % length of edge transients % Zero pad shorter coefficient vector as needed if nb < nfilt b(nfilt,1)=0; elseif na < nfilt a(nfilt,1)=0; end % Compute initial conditions to remove DC offset if nfilt>1 zi = ( eye(nfilt-1) - [-a(2:nfilt), [eye(nfilt-2); ... zeros(1,nfilt-2)]] ) \ ... ( b(2:nfilt) - b(1)*a(2:nfilt) ); else zi = zeros(0,1); end %% Filter the data for ii=1:L y = [2*x(1)-x(nfact+1:-1:2); x; 2*x(end)-x(end-1:-1:end-nfact)]; % filter, reverse data, filter again, and reverse data again y = filter(b(:,ii),a(:,ii),y,zi(:,ii)*y(1)); y = y(end:-1:1); y = filter(b(:,ii),a(:,ii),y,zi(:,ii)*y(1)); % retain reversed central section of y y = y(end-nfact:-1:nfact+1); end ================================================ FILE: Matlab/BasisOperations/histcounts_.m ================================================ function [N, binEdges] = histcounts_(d, nBinsIn, normalise) % own function for counting if nargin<2 || isempty(nBinsIn) nBinsIn = []; end if nargin<3 || isempty(normalise) normalise = false; end dMinMax = [min(d), max(d)]; dRange = dMinMax(2) - dMinMax(1); % fixed or automatic number of bins if isempty(nBinsIn) nBins = ceil(dRange/(3.5*std(d)/(numel(d)^(1/3)))); else nBins = nBinsIn; end % compute edges binWidth = dRange/nBins; binEdges = dMinMax(1) + (0:nBins)*binWidth; % count occurences in bins N = zeros(nBins, 1); d_ = d - dMinMax(1); for i = 1:length(d_) binInd = floor(d_(i)/binWidth)+1; binInd = max(1, binInd); binInd = min(nBins, binInd); N(binInd) = N(binInd) + 1; end % probability normalisation if normalise N = N./numel(d); end ================================================ FILE: Matlab/BasisOperations/myButter.m ================================================ function [Z_out, P_out] = myButter(n, W) % Digital Butterworth filter, either 2 or 3 outputs % Jan Simon, 2014, BSD licence % See docs of BUTTER for input and output % Fast hack with limited accuracy: Handle with care! % Until n=15 the relative difference to Matlab's BUTTER is < 100*eps V = tan(W * 1.5707963267948966); Q = exp((1.5707963267948966i / n) * ((2 + n - 1):2:(3 * n - 1))); nQ = length(Q); Sg = V ^ nQ; Sp = V * Q; Sz = []; % Bilinear transform: P = (1 + Sp) ./ (1 - Sp); Z = repmat(-1, size(P)); if isempty(Sz) G = real(Sg / prod(1 - Sp)); else G = real(Sg * prod(1 - Sz) / prod(1 - Sp)); Z(1:length(Sz)) = (1 + Sz) ./ (1 - Sz); end % From Zeros, Poles and Gain to B (numerator) and A (denominator): Z_out = G * real(poly(Z')); P_out = real(poly(P)); ================================================ FILE: Matlab/BasisOperations/poly_.m ================================================ function c = poly_(x) %POLY Convert roots to polynomial. % POLY(A), when A is an N by N matrix, is a row vector with % N+1 elements which are the coefficients of the % characteristic polynomial, det(lambda*eye(size(A)) - A). % % POLY(V), when V is a vector, is a vector whose elements are % the coefficients of the polynomial whose roots are the % elements of V. For vectors, ROOTS and POLY are inverse % functions of each other, up to ordering, scaling, and % roundoff error. % % Examples: % % roots(poly(1:20)) generates Wilkinson's famous example. % % Class support for inputs A,V: % float: double, single % % See also ROOTS, CONV, RESIDUE, POLYVAL. % Copyright 1984-2014 The MathWorks, Inc. [m,n] = size(x); if m == n % Characteristic polynomial (square x) e = eig(x); elseif (m==1) || (n==1) e = x; else error(message('MATLAB:poly:InputSize')) end % Strip out infinities e = e( isfinite(e) ); % Expand recursion formula n = length(e); c = [1 zeros(1,n,class(x))]; for j=1:n j c(2:(j+1)) e(j) c(1:j) e(j).*c(1:j) c(2:(j+1)) = c(2:(j+1)) - e(j).*c(1:j); end % The result should be real if the roots are complex conjugates. if isequal(sort(e(imag(e)>0)),sort(conj(e(imag(e)<0)))) c = real(c); end ================================================ FILE: Matlab/BasisOperations/splinefit.m ================================================ function pp = splinefit(y) %SPLINEFIT Fit a spline to noisy data. % PP = SPLINEFIT(X,Y,BREAKS) fits a piecewise cubic spline with breaks % (knots) BREAKS to the noisy data (X,Y). X is a vector and Y is a vector % or an ND array. If Y is an ND array, then X(j) and Y(:,...,:,j) are % matched. Use PPVAL to evaluate PP. % % PP = SPLINEFIT(X,Y,P) where P is a positive integer interpolates the % breaks linearly from the sorted locations of X. P is the number of % spline pieces and P+1 is the number of breaks. % % OPTIONAL INPUT % Argument places 4 to 8 are reserved for optional input. % These optional arguments can be given in any order: % % PP = SPLINEFIT(...,'p') applies periodic boundary conditions to % the spline. The period length is MAX(BREAKS)-MIN(BREAKS). % % PP = SPLINEFIT(...,'r') uses robust fitting to reduce the influence % from outlying data points. Three iterations of weighted least squares % are performed. Weights are computed from previous residuals. % % PP = SPLINEFIT(...,BETA), where 0 < BETA < 1, sets the robust fitting % parameter BETA and activates robust fitting ('r' can be omitted). % Default is BETA = 1/2. BETA close to 0 gives all data equal weighting. % Increase BETA to reduce the influence from outlying data. BETA close % to 1 may cause instability or rank deficiency. % % PP = SPLINEFIT(...,N) sets the spline order to N. Default is a cubic % spline with order N = 4. A spline with P pieces has P+N-1 degrees of % freedom. With periodic boundary conditions the degrees of freedom are % reduced to P. % % PP = SPLINEFIT(...,CON) applies linear constraints to the spline. % CON is a structure with fields 'xc', 'yc' and 'cc': % 'xc', x-locations (vector) % 'yc', y-values (vector or ND array) % 'cc', coefficients (matrix). % % Constraints are linear combinations of derivatives of order 0 to N-2 % according to % % cc(1,j)*y(x) + cc(2,j)*y'(x) + ... = yc(:,...,:,j), x = xc(j). % % The maximum number of rows for 'cc' is N-1. If omitted or empty 'cc' % defaults to a single row of ones. Default for 'yc' is a zero array. % % EXAMPLES % % % Noisy data % x = linspace(0,2*pi,100); % y = sin(x) + 0.1*randn(size(x)); % % Breaks % breaks = [0:5,2*pi]; % % % Fit a spline of order 5 % pp = splinefit(x,y,breaks,5); % % % Fit a spline of order 3 with periodic boundary conditions % pp = splinefit(x,y,breaks,3,'p'); % % % Constraints: y(0) = 0, y'(0) = 1 and y(3) + y"(3) = 0 % xc = [0 0 3]; % yc = [0 1 0]; % cc = [1 0 1; 0 1 0; 0 0 1]; % con = struct('xc',xc,'yc',yc,'cc',cc); % % % Fit a cubic spline with 8 pieces and constraints % pp = splinefit(x,y,8,con); % % % Fit a spline of order 6 with constraints and periodicity % pp = splinefit(x,y,breaks,con,6,'p'); % % See also SPLINE, PPVAL, PPDIFF, PPINT % Author: Jonas Lundgren 2010 % 2009-05-06 Original SPLINEFIT. % 2010-06-23 New version of SPLINEFIT based on B-splines. % 2010-09-01 Robust fitting scheme added. % 2010-09-01 Support for data containing NaNs. % 2011-07-01 Robust fitting parameter added. %Copyright (c) 2017, Jonas Lundgren % All rights reserved. % % Redistribution and use in source and binary forms, with or without % modification, are permitted provided that the following conditions are met: % % * Redistributions of source code must retain the above copyright notice, this % list of conditions and the following disclaimer. % % * Redistributions in binary form must reproduce the above copyright notice, % this list of conditions and the following disclaimer in the documentation % and/or other materials provided with the distribution % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" % AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE % IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE % DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE % FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL % DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR % SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER % CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, % OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE % OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. % inputs x = 1:length(y); breaks = [1, floor(length(y)/2), length(y)]; n = 4; beta = 0; dim = 1; % Evaluate B-splines [breaksB,coefsB,nB] = splinebase(breaks,n); % % Make piecewise polynomial % base = mkpp(breaksB,coefsB,nB); coder.varsize('coefsB',[8 4], [0 0]); % just don't use the struct... if nargin==2, nB = 1; else nB = nB(:).'; end dlk=numel(coefsB); l=length(breaksB)-1; dl=prod(nB)*l; k=fix(dlk/dl+100*eps); % if (k<=0)||(dl*k~=dlk) % error(message('MATLAB:mkpp:PPNumberMismatchCoeffs',... % int2str(l),int2str(d),int2str(dlk))) % end breaksBase = reshape(breaksB,1,l+1); coefsBase = coefsB; % reshape(coefsB,dl,k); lBase = l; kBase = k; dBase = nB; pieces = lBase; % try this to get around unbounded-error in Coder. coder.varsize('coefsBase',[8 4], [0 0]); base = mkpp(breaksBase,coefsBase,dBase); % lBase,kBase, A_base = ppval(base,x); % Bin data [junk,ibin] = histc(x,[-inf,breaks(2:end-1),inf]); %#ok % Sparse system matrix mx = numel(x); ii = [ibin; ones(n-1,mx)]; ii = cumsum(ii,1); jj = repmat(1:mx,n,1); A = zeros(pieces+n-1,mx); linIndices = sub2ind(size(A), ii, jj); A(linIndices)=A_base; % flipPoint = breaks(2)-1; % coder.varsize('flipPoint',[1 1], [0 0]); % A(1:end-1, 1:flipPoint) = A_base(:, 1:flipPoint); % A(2:end, (flipPoint+1):end) = A_base(:, (flipPoint+1):end); % Solve Min norm(u*A-y) u = lsqsolve(A,y,beta); % Compute polynomial coefficients ii = [repmat(1:pieces,1,n); ones(n-1,n*pieces)]; ii = cumsum(ii,1); jj = repmat(1:n*pieces,n,1); % C = sparse(ii,jj,base.coefs,pieces+n-1,n*pieces); C = zeros(pieces+n-1,n*pieces); linIndices = sub2ind(size(C), ii, jj); C(linIndices)=base.coefs; coefs = u*C; coefs = reshape(coefs,[],n); % Make piecewise polynomial pp = mkpp(breaks,coefs,dim); %-------------------------------------------------------------------------- function [breaks0,coefsOut,n] = splinebase(breaks0,n) %SPLINEBASE Generate B-spline base PP of order N for breaks BREAKS assert (n == 4); breaks0 = breaks0(:); % Breaks % breaks0 = breaks0'; % Initial breaks h0 = diff(breaks0); % Spacing pieces0 = numel(h0); % Number of pieces deg = n - 1; % Polynomial degree % distances between knots to replicate points to the sides hcopy = repmat(h0,ceil(deg/pieces0),1); % to the left hl = hcopy(end:-1:end-deg+1); bl = breaks0(1) - cumsum(hl); % and to the right hr = hcopy(1:deg); br = breaks0(end) + cumsum(hr); % Add breaks breaks = [bl(deg:-1:1); breaks0; br]; h = diff(breaks); pieces = numel(h); assert (pieces == 8); % Initiate polynomial coefficients coefs = zeros(n*pieces,n); coefs(1:n:end,1) = 1; % Expand h ii = [1:pieces; ones(deg,pieces)]; ii = cumsum(ii,1); ii = min(ii,pieces); H = h(ii(:)); % Recursive generation of B-splines for k = 2:n % Antiderivatives of splines for j = 1:k-1 coefs(:,j) = coefs(:,j).*H/(k-j); end Q = sum(coefs,2); Q = reshape(Q,n,pieces); Q = cumsum(Q,1); c0 = [zeros(1,pieces); Q(1:deg,:)]; coefs(:,k) = c0(:); % Normalize antiderivatives by max value fmax = repmat(Q(n,:),n,1); fmax = fmax(:); for j = 1:k coefs(:,j) = coefs(:,j)./fmax; end % Diff of adjacent antiderivatives coefs(1:end-deg,1:k) = coefs(1:end-deg,1:k) - coefs(n:end,1:k); coefs(1:n:end,k) = 0; end % Scale coefficients scale = ones(size(H)); for k = 1:n-1 scale = scale./H; coefs(:,n-k) = scale.*coefs(:,n-k); end % Reduce number of pieces pieces = pieces - 2*deg; % Sort coefficients by interval number ii = [n*(1:pieces); deg*ones(deg,pieces)]; ii = cumsum(ii,1); coefsOut = coefs(ii(:),:); coder.varsize('coefsOut',[8 4], [0 0]); %-------------------------------------------------------------------------- function u = lsqsolve(A,y,beta) %LSQSOLVE Solve Min norm(u*A-y) % Solution u = y/A; % % Robust fitting % if beta > 0 % [m,n] = size(y); % alpha = 0.5*beta/(1-beta)/m; % for k = 1:3 % % Residual % r = u*A - y; % rr = r.*conj(r); % rrmean = sum(rr,2)/n; % rrmean(~rrmean) = 1; % rrhat = (alpha./rrmean)'*rr; % % Weights % w = exp(-rrhat); % spw = spdiags(w',0,n,n); % % Solve weighted problem % u = (y*spw)/(A*spw); % end % end ================================================ FILE: Matlab/BasisOperations/test_zp2ss.m ================================================ function out = test_zp2ss(z,p,k) out = zp2ss(z,p,k); ================================================ FILE: Matlab/BasisOperations/testfilt.m ================================================ % testFilter fileID = fopen('/Users/carl/PycharmProjects/catch22/C/timeSeries/tsid0133.txt','r'); tsData = fscanf(fileID,'%f'); fclose(fileID); [b, a] = myButter(4, 0.8/24); tsDatafilt = filter(b,a,tsData) ================================================ FILE: Matlab/BasisOperations/welchy.m ================================================ function [Pxx, F] = calc_psd(X, NFFT, Fs, WINDOW) % Calculate Power Spectral Density % [Pxx ,F]= PSD(X, NFFT, Fs, WINDOW) estimates the Power Spectral Density of % signal vector X using Welch's averaged periodogram method. X is % divided into sections, then windowed by the WINDOW parameter % The magnitude squared of the length NFFT DFTs of the sections are % averaged to form Pxx. Pxx is length NFFT/2+1 for NFFT even. the default fot WINDOW is a rectangular window . % Fs is the sampling frequency which is used for scaling of plots. % % Author(s): T. Krauss, 3-26-93 % Copyright (c) 1984-94 by The MathWorks, Inc. % Revision: Roni P, 10.8.01 % EU, dt used in computations % EU, df used to get frequency scale % X - The signal we want to estimate the psd for. % NFFT - number of data points of each window % Fs - Sampling frequency % Window - The type of window to use % Example of use: % dt = 0.01; % f = 10; % Frequency to find % t = 0:dt:10; % Create time vector % x = sin(2*pi*f*t); % create a signal % nfft = 64; % Window should be less than 256. % Fs = 1/dt; % Sampling frequency % window = hanning(nfft); % Use hanning as window % [Pxx, F] = calc_psd(x, nfft, Fs, window); % plot(F,Pxx); xlabel('Frequency [Hz]'); ylabel('Amplitude'); if (nargin <= 2) error('Not enough input parameters, exiting...'); end % % make sure the windows width is a power of 2 % NFFT = 2^(nextpow2(NFFT)-1); % this stinks. windowWidth = numel(WINDOW);%2^(nextpow2(numel(WINDOW))-1); % dt = 1/Fs; df = 1/(2^(nextpow2(numel(WINDOW))))/dt; if (nargin == 3) w = ones(windowWidth, 1); end if (nargin == 4) w = WINDOW; w = w(:); % Make sure w is a column vector end X = X(:); % Make sure X is a column vector k = floor(numel(X)/(windowWidth/2))-1; % Number of windows index = 1:windowWidth; KMU = k*norm(w)^2; % Normalizing scale factor w = w(:); P = zeros(NFFT, 1); for i = 1:k xw = w.*X(index); index = index + windowWidth/2; % Continue to next window P = P + abs(fft(xw, NFFT)).^2; end Pxx = dt*(P(1:NFFT/2+1))/KMU; % strange correction here, don't know why it's neccesary!! Pxx(2:end-1) = Pxx(2:end-1)*2; n = max(size(Pxx)); F = (0:n-1)'*df; ================================================ FILE: Matlab/CO_Embed2_Dist_tau_d_expfit_meandiff.m ================================================ function out = CO_Embed2_Dist_tau_d_expfit_meandiff(y) % CO_Embed2_Dist Analyzes distances in a 2-d embedding space of a time series. % % Returns statistics on the sequence of successive Euclidean distances between % points in a two-dimensional time-delay embedding space with a given % time-delay, tau. % % Outputs the the mean distance, the % spread of distances, and statistics from an exponential fit to the % distribution of distances. % %---INPUTS: % y, a z-scored column vector representing the input time series. % tau, the time delay. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); % ------------------------------------------------------------------------------ %% Check inputs: % ------------------------------------------------------------------------------ N = length(y); % time-series length tau = CO_FirstZero(y,'ac'); if tau > N/10 tau = floor(N/10); end % ------------------------------------------------------------------------------ % 2-dimensional time-delay embedding: % ------------------------------------------------------------------------------ m = [y(1:end-tau), y(1+tau:end)]; % ------------------------------------------------------------------------------ % Calculate Euclidean distances between successive points in this space, d: % ------------------------------------------------------------------------------ d = sqrt(diff(m(:,1)).^2 + diff(m(:,2)).^2); % Euclidean distance % % ------------------------------------------------------------------------------ % % Empirical distance distribution often fits Exponential distribution quite well % % Fit to all values (often some extreme outliers, but oh well) % l = expfit(d); l = mean(d); % maybe this is stupid, but I seriously don't see the difference %% Sum of abs differences between exp fit and observed: [N, binEdges] = histcounts_(d, [], true); % from edges to centers binCentres = mean([binEdges(1:end-1); binEdges(2:end)])'; % exponential fit in each bin z = binCentres ./ l; expf = exp(-z) ./ l; expf(expf<0) = 0; d_expfit_meandiff = mean(abs(N - expf)); % mean absolute error of fit out = d_expfit_meandiff; end ================================================ FILE: Matlab/CO_FirstMin_ac.m ================================================ function out = CO_FirstMin_ac(y) % CO_FirstMin Time of first minimum in a given correlation function % %---INPUTS: % y, the input time series % % Note that selecting 'ac' is unusual operation: standard operations are the % first zero-crossing of the autocorrelation (as in CO_FirstZero), or the first % minimum of the mutual information function ('mi'). % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); N = length(y); % Time-series length % ------------------------------------------------------------------------------ % Define the autocorrelation function % ------------------------------------------------------------------------------ % Autocorrelation implemented as CO_AutoCorr corrfn = @(x) CO_AutoCorr(y,x,'Fourier'); % ------------------------------------------------------------------------------ % Search for a minimum % ------------------------------------------------------------------------------ % (Incrementally through time lags until a minimum is found) autoCorr = zeros(N-1,1); % preallocate autocorrelation vector for i = 1:N-1 % Calculate the auto-correlation at this lag: autoCorr(i) = corrfn(i); % Hit a NaN before got to a minimum -- there is no minimum if isnan(autoCorr(i)) % warning('No minimum in %s [[time series too short to find it?]]',minWhat) out = NaN; return end % We're at a minimum: if i==2 && (autoCorr(2) > autoCorr(1)) % already increases at lag of 2 from lag of 1: a minimum (since ac(0) is maximal) out = 1; return elseif (i > 2) && (autoCorr(i-2) > autoCorr(i-1)) && (autoCorr(i-1) < autoCorr(i)) % minimum at previous i out = i-1; % I found the first minimum! return end end % Still decreasing -- no minimum was found after searching all across the time series: out = N; end ================================================ FILE: Matlab/CO_HistogramAMI_even_2_5.m ================================================ function out = CO_HistogramAMI_even_2_5(y) % CO_HistogramAMI The automutual information of the distribution using histograms. % % The approach used to bin the data is provided. % %---INPUTS: % % y, the input time series % % tau, 2: the time-lag % % meth, 'even': evenly-spaced bins through the range of the time series, % % numBins, 5: the number of bins % %---OUTPUT: the automutual information calculated in this way. % Uses the hist2 function (renamed NK_hist2.m here) by Nedialko Krouchev, obtained % from Matlab Central, % http://www.mathworks.com/matlabcentral/fileexchange/12346-hist2-for-the-people % [[hist2 for the people by Nedialko Krouchev, 20 Sep 2006 (Updated 21 Sep 2006)]] % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); % ------------------------------------------------------------------------------ %% Check Inputs: % ------------------------------------------------------------------------------ % Number of options: % remove outliers first?, number of bins, range of bins, bin sizes tau = 2; % meth = 'even'; numBins = 5; % ------------------------------------------------------------------------------ %% Bins by standard deviation (=1) % ------------------------------------------------------------------------------ % even b = linspace(min(y)-0.1,max(y)+0.1,numBins+1); % +0.1 to make sure all points included nb = length(b) - 1; % number of bins (-1 since b defines edges) % ------------------------------------------------------------------------------ % Form the time-delay vectors y1 and y2 % ------------------------------------------------------------------------------ y1 = y(1:end-tau); y2 = y(1+tau:end); % (1) Joint distribution of y1 and y2 pij = NK_hist2(y1,y2,b,b); pij = pij(1:nb,1:nb); % joint pij = pij/sum(sum(pij)); % joint pi = sum(pij,1); % marginal pj = sum(pij,2); % other marginal % Old-fashioned method (should give same result): % pi = histc(y1,b); pi = pi(1:nb); pi = pi/sum(pi); % marginal % pj = histc(y2,b); pj= pj(1:nb); pj = pj/sum(pj); % other marginal pii = ones(nb,1)*pi; pjj = pj*ones(1,nb); r = (pij > 0); % Defining the range in this way, we set log(0) = 0 ami = sum(pij(r).*log(pij(r)./pii(r)./pjj(r))); out = ami; end ================================================ FILE: Matlab/CO_f1ecac.m ================================================ function out = CO_f1ecac(y) % CO_f1ecac The 1/e correlation length % % Finds where autocorrelation function first crosses 1/e % %---INPUT: % y, the input time series. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); N = length(y); % time-series length thresh = 1/exp(1); % 1/e threshold a = zeros(N,1); % autocorrelations a(1) = 1; % perfect autocorrelation when no lag for i = 2:N a(i) = CO_AutoCorr(y,i-1,'Fourier'); if ((a(i-1)-thresh)*(a(i)-thresh) < 0) % Crossed the 1/e line out = i-1; % -1 since i is tau+1 return end end % If no minimum in entire spectrum return the maximum value out = N; end ================================================ FILE: Matlab/CO_trev_1_num.m ================================================ function out = CO_trev_1_num(y) % no combination of single functions coder.inline('never'); outStruct = CO_trev(y, 1); out = outStruct.num; ================================================ FILE: Matlab/DN_HistogramMode_10.m ================================================ function out = DN_HistogramMode_10(y) % no combination of single functions coder.inline('never'); out = DN_HistogramMode(y, 10); ================================================ FILE: Matlab/DN_HistogramMode_5.m ================================================ function out = DN_HistogramMode_5(y) % no combination of single functions coder.inline('never'); out = DN_HistogramMode(y, 5); ================================================ FILE: Matlab/DN_Mean.m ================================================ function out = DN_Mean(y) % no combination of single functions coder.inline('never'); out = DN_Mean(y, 5); ================================================ FILE: Matlab/DN_OutlierInclude_n_001_mdrmd.m ================================================ function out = DN_OutlierInclude_n_001_mdrmd(y) % no combination of single functions coder.inline('never'); out = DN_OutlierInclude_001_mdrmd(y, 'n'); ================================================ FILE: Matlab/DN_OutlierInclude_p_001_mdrmd.m ================================================ function out = DN_OutlierInclude_p_001_mdrmd(y) % no combination of single functions coder.inline('never'); out = DN_OutlierInclude_001_mdrmd(y, 'p'); ================================================ FILE: Matlab/DN_Spread_Std.m ================================================ function out = DN_Spread_Std(y) % no combination of single functions coder.inline('never'); out = DN_Spread_Std(y, 5); ================================================ FILE: Matlab/FC_LocalSimple_mean1_tauresrat.m ================================================ function out = FC_LocalSimple_mean1_tauresrat(y) % FC_LocalSimple Simple local time-series forecasting. % % Simple predictors using the past trainLength values of the time series to % predict its next value. % %---INPUTS: % y, the input time series % % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); % ------------------------------------------------------------------------- %% Set defaults % ------------------------------------------------------------------------- trainLength = 1; N = length(y); % Time-series length % ------------------------------------------------------------------------------ % Do the local prediction % ------------------------------------------------------------------------------ if strcmp(trainLength,'ac') lp = CO_FirstZero(y,'ac'); % make it tau else lp = trainLength; % the length of the subsegment preceeding to use to predict the subsequent value end evalr = lp+1:N; % range over which to evaluate the forecast if length(evalr)==0 % warning('Time series too short for forecasting'); out = NaN; return end res = zeros(length(evalr),1); % residuals for i = 1:length(evalr) res(i) = mean(y(evalr(i)-lp:evalr(i)-1)) - y(evalr(i)); % prediction-value end % tauresrat out = CO_FirstZero(res,'ac')/CO_FirstZero(y,'ac'); end ================================================ FILE: Matlab/FC_LocalSimple_mean3_stderr.m ================================================ function out = FC_LocalSimple_mean3_stderr(y) % FC_LocalSimple Simple local time-series forecasting. % % Simple predictors using the past trainLength values of the time series to % predict its next value. % %---INPUTS: % y, the input time series % % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); %------------------------------------------------------------------------------- %% Set defaults: %------------------------------------------------------------------------------- trainLength = 3; N = length(y); % Time-series length % ------------------------------------------------------------------------------ % Do the local prediction % ------------------------------------------------------------------------------ lp = trainLength; % the length of the subsegment preceeding to use to predict the subsequent value evalr = lp+1:N; % range over which to evaluate the forecast if length(evalr)==0 % warning('Time series too short for forecasting'); out = NaN; return end res = zeros(length(evalr),1); % residuals for i = 1:length(evalr) res(i) = mean(y(evalr(i)-lp:evalr(i)-1)) - y(evalr(i)); % prediction-value end % Spread of residuals: % stderr out = std(res); end ================================================ FILE: Matlab/IN_AutoMutualInfoStats_40_gaussian_fmmi.m ================================================ function out = IN_AutoMutualInfoStats_40_gaussian_fmmi(y) % IN_AutoMutualInfoStats Statistics on automutual information function for a time series. % %---INPUTS: % y, column vector of time series data % % maxTau, maximal time delay % % estMethod = 'gaussian' % %---OUTPUTS: % out = fmmi, statistic on the AMIs and their pattern across % the range of specified time delays. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); % ------------------------------------------------------------------------------ %% Preliminaries % ------------------------------------------------------------------------------ N = length(y); % length of time series % ------------------------------------------------------------------------------ %% Check Inputs % ------------------------------------------------------------------------------ % maxTau: the maximum time delay to investigate maxTau = 40; % Don't go above N/2 maxTau = min(maxTau,ceil(N/2)); % ------------------------------------------------------------------------------ %% Get the AMI data: % ------------------------------------------------------------------------------ % do this manually, Gaussian really is the easiest MI autocorrs = autocorrelation(y, maxTau); ami = -0.5*log(1 - autocorrs.^2); % ------------------------------------------------------------------------------ % Output statistics: % ------------------------------------------------------------------------------ lami = length(ami); % First minimum of mutual information across range dami = diff(ami); extremai = find(dami(1:end-1).*dami(2:end) < 0 & dami(1:end-1)<0); if isempty(extremai) % fmmi out = lami; % actually represents lag, because indexes don't but diff delays by 1 else % fmmi out = min(extremai); end end function out = autocorrelation(y, maxLag) N = length(y); if maxLag >= N maxLag = N-1; end out = zeros(1,maxLag); for lag = 1:maxLag corrs = corrcoef(y(1:end-lag), y(1+lag:end)); out(lag) = corrs(2,1); end end ================================================ FILE: Matlab/MD_hrv_classic_pnn40.m ================================================ function out = MD_hrv_classic_pnn40(y) % MD_hrv_classic Classic heart rate variability (HRV) statistics. % % Typically assumes an NN/RR time series in units of seconds. % %---INPUTS: % y, the input time series. % %---OUTPUTS: % pNN40 % cf. "The pNNx files: re-examining a widely used heart rate variability % measure", J.E. Mietus et al., Heart 88(4) 378 (2002) % % Code is heavily derived from that provided by Max A. Little: % http://www.maxlittle.net/ % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); % Standard defaults diffy = diff(y); N = length(y); % time-series length % ------------------------------------------------------------------------------ % Calculate pNNx percentage % ------------------------------------------------------------------------------ % pNNx: recommendation as per Mietus et. al. 2002, "The pNNx files: ...", Heart % strange to do this for a z-scored time series... % pnntime = 20; Dy = abs(diffy) * 1000; % Anonymous function to do the PNNx calcualtion: PNNxfn = @(x) sum(Dy > x)/(N-1); % % exceed = sum(Dy > pnntime); % out.pnn5 = PNNxfn(5); %sum(Dy > 5)/(N-1); % proportion of difference magnitudes greater than 0.005*sigma % out.pnn10 = PNNxfn(10); %sum(Dy > 10)/(N-1); % out.pnn20 = PNNxfn(20); %sum(Dy > 20)/(N-1); % out.pnn30 = PNNxfn(30); %sum(Dy > 30)/(N-1); % pnn40 out = PNNxfn(40); %sum(Dy > 40)/(N-1); end ================================================ FILE: Matlab/PD_PeriodicityWang_th0_01.m ================================================ function out = PD_PeriodicityWang_th0_01(y_in) % PD_PeriodicityWang Periodicity extraction measure of Wang et al. % % Implements an idea based on the periodicity extraction measure proposed in: % % "Structure-based Statistical Features and Multivariate Time Series Clustering" % Wang, X. and Wirth, A. and Wang, L. % Seventh IEEE International Conference on Data Mining, 351--360 (2007) % DOI: 10.1109/ICDM.2007.103 % % Detrends the time series using a single-knot cubic regression spline % and then computes autocorrelations up to one third of the length of % the time series. The frequency is the first peak in the autocorrelation % function satisfying a set of conditions. % % This code uses the SPLINEFIT v1.13.0.0 function by Jonas Lundgren from % Matlab Central accessed on 25 Aug 2018. % %---INPUT: % y, the input time series. % % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); % ------------------------------------------------------------------------------ %% Foreplay % ------------------------------------------------------------------------------ N = length(y_in); % length of the time series th = 0.01; % [0, 0.01, 0.1, 0.2, 1/sqrt(N), 5/sqrt(N), 10/sqrt(N)]; % the thresholds with which to count a peak % ------------------------------------------------------------------------------ %% 1: Detrend using a regression spline with 3 knots % ------------------------------------------------------------------------------ ppSpline = splinefit(y_in'); y_spl = ppval(ppSpline,1:N); % x = (ppSpline.breaks(1):ppSpline.breaks(2))-1; % y_spl_1 = ppSpline.coefs(1,1)*x.^3 + ppSpline.coefs(1,2)*x.^2 + ppSpline.coefs(1,3)*x.^1 + ppSpline.coefs(1,4); % x = (ppSpline.breaks(2):ppSpline.breaks(3))-ppSpline.breaks(2)+1; % y_spl_2 = ppSpline.coefs(2,1)*x.^3 + ppSpline.coefs(2,2)*x.^2 + ppSpline.coefs(2,3)*x.^1 + ppSpline.coefs(2,4); % y_spl = [y_spl_1, y_spl_2]; y = y_in - y_spl'; %% 2. Compute autocorrelations up to 1/3 the length of the time series. acmax = ceil(N/3); % compute autocorrelations up to this lag acf = zeros(acmax,1); % the autocorrelation function for i = 1:acmax % i is the \tau, the AC lag acf(i) = mean(y(1:N-i).*y(i+1:N)); end % ------------------------------------------------------------------------------ %% 3. Frequency is the first peak satisfying the following conditions: % ------------------------------------------------------------------------------ % (a) a trough before it % (b) difference between peak and trough is at least 0.01 % (c) peak corresponds to positive correlation % (i) find peaks and troughs in ACF diffac = diff(acf); % differenced time series sgndiffac = sign(diffac); % sign of differenced time series bath = diff(sgndiffac); % differenced, signed, differenced time series troughs = find(bath == 2) + 1; % finds troughs peaks = find(bath == -2) + 1; % finds peaks npeaks = length(peaks); out = 0; for i = 1:npeaks % search through all peaks for one that meets the condition ipeak = peaks(i); % acf lag at which there is a peak thepeak = acf(ipeak); % acf at the peak ftrough = find(troughs < ipeak,1,'last'); if isempty(ftrough); continue; end itrough = troughs(ftrough); % acf lag at which there is a trough (the first one preceeding the peak) thetrough = acf(itrough); % acf at the trough % (a) a trough before it: should be implicit in the ftrough bit above % if troughs(1)>ipeak % the first trough is after it % continue % end % (b) difference between peak and trough is at least 0.01 if thepeak - thetrough < th continue end % (c) peak corresponds to positive correlation if thepeak < 0 continue end % we made it! Use this frequency! out = ipeak; break end end ================================================ FILE: Matlab/SB_BinaryStats_diff_longstretch0.m ================================================ function out = SB_BinaryStats_diff_longstretch0(y) % SB_BinaryStats Statistics on a binary symbolization of the time series % % Binary symbolization of the time series is a symbolic string of 0s and 1s. % % Provides information about the coarse-grained behavior of the time series % %---INPUTS: % y, the input time series % % binaryMethod, the symbolization rule: % 'diff': by whether incremental differences of the time series are % positive (1), or negative (0), % %---OUTPUTS: % Include the Shannon entropy of the string, the longest stretches of 0s % or 1s, the mean length of consecutive 0s or 1s, and the spread of consecutive % strings of 0s or 1s. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); %------------------------------------------------------------------------------- % Set defaults: %------------------------------------------------------------------------------- binaryMethod = 'diff'; %------------------------------------------------------------------------------- % Binarize the time series: %------------------------------------------------------------------------------- yBin = BF_Binarize(y,binaryMethod); %------------------------------------------------------------------------------- % Consecutive string of ones / zeros (normalized by length) %------------------------------------------------------------------------------- difffy = diff(find([1;yBin;1])); stretch0 = difffy(difffy ~= 1) - 1; %------------------------------------------------------------------------------- % pstretches %------------------------------------------------------------------------------- if isempty(stretch0) % all 1s (almost impossible to actually occur) longstretch0 = 0; else longstretch0 = max(stretch0); % longest consecutive stretch of zeros end out = longstretch0; end ================================================ FILE: Matlab/SB_BinaryStats_mean_longstretch1.m ================================================ function out = SB_BinaryStats_mean_longstretch1(y) % SB_BinaryStats Statistics on a binary symbolization of the time series % % Binary symbolization of the time series is a symbolic string of 0s and 1s. % % Provides information about the coarse-grained behavior of the time series % %---INPUTS: % y, the input time series % % binaryMethod, the symbolization rule: % 'diff': by whether incremental differences of the time series are % positive (1), or negative (0), % %---OUTPUTS: % Include the Shannon entropy of the string, the longest stretches of 0s % or 1s, the mean length of consecutive 0s or 1s, and the spread of consecutive % strings of 0s or 1s. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); %------------------------------------------------------------------------------- % Set defaults: %------------------------------------------------------------------------------- binaryMethod = 'mean'; %------------------------------------------------------------------------------- % Binarize the time series: %------------------------------------------------------------------------------- yBin = BF_Binarize(y,binaryMethod); %------------------------------------------------------------------------------- % Consecutive string of ones (normalized by length) %------------------------------------------------------------------------------- difffy = diff(find([0;yBin;0] == 0)); stretch1 = difffy(difffy ~= 1) - 1; %------------------------------------------------------------------------------- % pstretches %------------------------------------------------------------------------------- if isempty(stretch1) % all 1s (almost impossible to actually occur) longstretch1 = 0; else longstretch1 = max(stretch1); % longest consecutive stretch of zeros end out = longstretch1; end ================================================ FILE: Matlab/SB_MotifThree_quantile_hh.m ================================================ function out = SB_MotifThree_quantile_hh(y) % SB_MotifThree Motifs in a coarse-graining of a time series to a 3-letter alphabet % % (As SB_MotifTwo but with a 3-letter alphabet) % %---INPUTS: % y, time series to analyze % cgHow, the coarse-graining method to use. 'quantile': equiprobable alphabet by time-series value % %---OUTPUTS: % Statistics on words of length 1, 2, 3, and 4. % ------------------------------------------------------------------------------ % Copyright (C) 2017, Ben D. Fulcher , % % % If you use this code for your research, please cite the following two papers: % % (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated % Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). % DOI: 10.1016/j.cels.2017.10.001 % % (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series % analysis: the empirical structure of time series and their methods", % J. Roy. Soc. Interface 10(83) 20130048 (2013). % DOI: 10.1098/rsif.2013.0048 % % This function is free software: you can redistribute it and/or modify it under % the terms of the GNU General Public License as published by the Free Software % Foundation, either version 3 of the License, or (at your option) any later % version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more % details. % % You should have received a copy of the GNU General Public License along with % this program. If not, see . % ------------------------------------------------------------------------------ % no combination of single functions coder.inline('never'); %------------------------------------------------------------------------------- %% Set defaults: %------------------------------------------------------------------------------- % quantile graining yt = SB_CoarseGrain_quantile(y,3); N = length(yt); % Length of the symbolized sequence derived from the time series % So we have a vector yt with entries \in {1,2,3} % ------------------------------------------------------------------------------ %% Words of length 1 % ------------------------------------------------------------------------------ r1 = cell(3,1); % stores ranges as vectors % out1 = zeros(3,1); % stores probabilities as doubles for i = 1:3 r1{i} = find(yt == i); % out1(i) = length(r1{i})/N; end % ------------------------------------------------------------------------------ %% Words of length 2 % ------------------------------------------------------------------------------ % Make sure ranges are valid for looking at the next one for i = 1:3 if (~isempty(r1{i})) && (r1{i}(end) == N) r1{i} = r1{i}(1:end-1); end end r2 = cell(3,3); out2 = zeros(3,3); for i = 1:3 for j = 1:3 r2{i,j} = r1{i}(yt(r1{i}+1) == j); out2(i,j) = length(r2{i,j})/(N-1); end end % hh out = f_entropy(out2); % entropy of this result %------------------------------------------------------------------------------- function h = f_entropy(x) % entropy of a set of counts, log(0)=0 h = -sum(x(x > 0).*log(x(x > 0))); end end ================================================ FILE: Matlab/SB_TransitionMatrix_3ac_sumdiagcov.m ================================================ function out = SB_TransitionMatrix_3ac_sumdiagcov(y) % no combination of single functions coder.inline('never'); outStruct = SB_TransitionMatrix(y, 3, 'ac'); out = outStruct.sumdiagcov; ================================================ FILE: Matlab/SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1.m ================================================ function out = SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1(y) % no combination of single functions coder.inline('never'); out = SC_FluctAnal_q2_taustep50_k1_logi_prop_r1(y, 'dfa', 2); ================================================ FILE: Matlab/SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1.m ================================================ function out = SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1(y) % no combination of single functions coder.inline('never'); out = SC_FluctAnal_q2_taustep50_k1_logi_prop_r1(y, 'rsrangefit'); ================================================ FILE: Matlab/SP_Summaries_welch_rect_area_5_1.m ================================================ function out = SP_Summaries_welch_rect_area_5_1(y) % no combination of single functions coder.inline('never'); outStruct = SP_Summaries_welch_rect(y); out = outStruct.area_5_1; ================================================ FILE: Matlab/SP_Summaries_welch_rect_centroid.m ================================================ function out = SP_Summaries_welch_rect_centroid(y) % no combination of single functions coder.inline('never'); outStruct = SP_Summaries_welch_rect(y); out = outStruct.centroid; ================================================ FILE: README.md ================================================

catch22 logo

catch22: CAnonical Time-series CHaracteristics

_catch22_ is a collection of 22 time-series features coded in C that can be run from Python, R, Matlab, and Julia, licensed under the [GNU GPL v3 license](http://www.gnu.org/licenses/gpl-3.0.html) (or later). The _catch22_ features are a high-performing subset of the over 7000 features in [_hctsa_](https://github.com/benfulcher/hctsa). The features were selected based on their classification performance across a collection of 93 real-world time-series classification problems, as described in our open-access paper, [📗 Lubba et al. (2019). _catch22_: CAnonical Time-series CHaracteristics](https://doi.org/10.1007/s10618-019-00647-x). ## [📙📘📗___catch22_ documentation__](https://time-series-features.gitbook.io/catch22/) There is [comprehensive documentation](https://time-series-features.gitbook.io/catch22/) for _catch22_, including: - Installation instructions (across C, python, R, Julia, and Matlab) - Information about the theory behind and behavior of each of the features, - A list of publications that have used or extended _catch22_ - And more :yum: ## Installation and Usage in Python, R, Matlab, Julia, and compiled C There are also native versions of this code for other programming languages: - [Rcatch22](https://github.com/hendersontrent/Rcatch22) (R) `install.packages("Rcatch22")` - [pycatch22](https://github.com/DynamicsAndNeuralSystems/pycatch22) (python) `pip install pycatch22` - [Catch22.jl](https://github.com/brendanjohnharris/Catch22.jl) (Julia) `Pkg.add("Catch22")` You can also use the C-compiled features directly, or in Matlab, following the [detailed installation instructions in the documentation](https://time-series-features.gitbook.io/catch22/). ## Acknowledgement :+1: If you use this software, please read and cite this open-access article: - 📗 Lubba et al. [_catch22_: CAnonical Time-series CHaracteristics](https://doi.org/10.1007/s10618-019-00647-x), _Data Min Knowl Disc_ __33__, 1821 (2019). ## Performance Summary Summary of the performance of the _catch22_ feature set across 93 classification problems, and a comparison to the [_hctsa_ feature set](https://github.com/benfulcher/hctsa) (cf. Fig. 4 from [our paper](https://doi.org/10.1007/s10618-019-00647-x)): ![](img/PerformanceComparisonFig4.png) ## Notes - When presenting results using _catch22_, you must identify the version used to allow clear reproduction of your results. For example, `CO_f1ecac` was altered from an integer-valued output to a linearly interpolated real-valued output from v0.3. - _catch22_ features only evaluate _dynamical_ properties of time series and do not respond to basic differences in the location (e.g., mean) or spread (e.g., variance). - If the location and spread of the raw time-series distribution may be important for your application, you should apply the function argument `catch24 = true` (`TRUE` in R, `True` in Python) to your call to the _catch22_ function in the language of your choice. This will result in 24 features being calculated: the _catch22_ features in addition to mean and standard deviation. - Time series are _z_-scored internally (for features other than mean and standard deviation), which means that, e.g., constant time series will lead to `NaN` outputs. - Time-series data are taken as an ordered sequence of values (without time stamps). We assume an evenly sampled time series. - See language-specific usage information in the [docs](https://time-series-features.gitbook.io/catch22/). - The computational pipeline used to generate the _catch22_ feature set is in the [`op_importance`](https://github.com/chlubba/op_importance) repository. ================================================ FILE: catch22.m ================================================ function out = catch22(y) % catch22 Compute all 22 catch22 features % No combination of single functions coder.inline('never'); % First z-score: y = (y - mean(y))/std(y); out = zeros(22,1); out(1) = DN_HistogramMode_5(y); out(2) = DN_HistogramMode_10(y); out(3) = CO_f1ecac(y); out(4) = CO_FirstMin_ac(y); out(5) = CO_HistogramAMI_even_2_5(y); out(6) = CO_trev_1_num(y); out(7) = MD_hrv_classic_pnn40(y); out(8) = SB_BinaryStats_mean_longstretch1(y); out(9) = SB_TransitionMatrix_3ac_sumdiagcov(y); out(10) = PD_PeriodicityWang_th0_01(y); out(11) = CO_Embed2_Dist_tau_d_expfit_meandiff(y); out(12) = IN_AutoMutualInfoStats_40_gaussian_fmmi(y); out(13) = FC_LocalSimple_mean1_tauresrat(y); out(14) = DN_OutlierInclude_p_001_mdrmd(y); out(15) = DN_OutlierInclude_n_001_mdrmd(y); out(16) = SP_Summaries_welch_rect_area_5_1(y); out(17) = SB_BinaryStats_diff_longstretch0(y); out(18) = SB_MotifThree_quantile_hh(y); out(19) = SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1(y); out(20) = SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1(y); out(21) = SP_Summaries_welch_rect_centroid(y); out(22) = FC_LocalSimple_mean3_stderr(y); end ================================================ FILE: featureList.txt ================================================ # Full_feature_name_code short_feature_name # --------------------------------------------------------------- DN_HistogramMode_5 mode_5 DN_HistogramMode_10 mode_10 DN_OutlierInclude_p_001_mdrmd outlier_timing_pos DN_OutlierInclude_n_001_mdrmd outlier_timing_neg CO_f1ecac acf_timescale CO_FirstMin_ac acf_first_min SP_Summaries_welch_rect_area_5_1 low_freq_power SP_Summaries_welch_rect_centroid centroid_freq FC_LocalSimple_mean3_stderr forecast_error FC_LocalSimple_mean1_tauresrat whiten_timescale MD_hrv_classic_pnn40 high_fluctuation SB_BinaryStats_mean_longstretch1 stretch_high SB_BinaryStats_diff_longstretch0 stretch_decreasing SB_MotifThree_quantile_hh entropy_pairs CO_HistogramAMI_even_2_5 ami2 CO_trev_1_num trev IN_AutoMutualInfoStats_40_gaussian_fmmi ami_timescale SB_TransitionMatrix_3ac_sumdiagcov transition_variance PD_PeriodicityWang_th0_01 periodicity CO_Embed2_Dist_tau_d_expfit_meandiff embedding_dist SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1 rs_range SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1 dfa DN_Mean mean DN_Spread_Std std ================================================ FILE: testData/runtests.sh ================================================ #!/bin/bash "$(dirname -- $0)/../C/runAllTS.sh" -i "$(dirname -- $0)" -o "$(dirname -- $0)" -a "_output" -s 1 -i "$(dirname -- $0)" -o "$(dirname -- $0)" -a "_output" -s 1 ================================================ FILE: testData/test.txt ================================================ -0.89094 -0.86099 -0.82438 -0.78214 -0.73573 -0.68691 -0.63754 -0.58937 -0.54342 -0.50044 -0.46082 -0.42469 -0.3924 -0.36389 -0.33906 -0.31795 -0.30056 -0.28692 -0.27727 -0.27105 -0.26777 -0.26678 -0.26742 -0.26927 -0.27202 -0.27529 -0.27898 -0.2832 -0.28814 -0.29431 -0.30185 -0.31086 -0.32135 -0.33326 -0.3465 -0.36103 -0.37659 -0.39297 -0.40995 -0.42731 -0.44484 -0.46226 -0.47921 -0.49534 -0.51031 -0.52382 -0.53567 -0.54568 -0.55375 -0.55984 -0.56397 -0.56617 -0.56653 -0.56511 -0.56201 -0.55736 -0.55133 -0.54419 -0.53617 -0.52758 -0.51876 -0.51004 -0.50174 -0.49418 -0.48731 -0.48128 -0.47619 -0.4721 -0.46921 -0.4674 -0.46649 -0.46659 -0.46785 -0.47045 -0.4749 -0.48081 -0.48822 -0.49726 -0.50805 -0.52086 -0.53596 -0.55266 -0.57081 -0.59021 -0.61063 -0.63238 -0.65484 -0.67722 -0.69907 -0.72004 -0.73987 -0.75965 -0.77816 -0.79527 -0.8109 -0.82509 -0.83844 -0.85159 -0.86373 -0.87474 -0.88447 -0.8929 -0.90125 -0.90911 -0.91606 -0.92197 -0.92677 -0.93071 -0.93528 -0.93931 -0.9426 -0.94494 -0.94622 -0.94735 -0.94879 -0.94965 -0.94971 -0.94878 -0.94679 -0.94571 -0.94428 -0.94176 -0.93756 -0.9311 -0.92258 -0.91342 -0.90142 -0.88573 -0.86549 -0.83998 -0.81054 -0.77682 -0.73745 -0.692 -0.64033 -0.58278 -0.52295 -0.45966 -0.39357 -0.32536 -0.2557 -0.18627 -0.11888 -0.052529 0.012911 0.077684 0.14195 0.2039 0.26391 0.3225 0.37976 0.43566 0.48977 0.53999 0.58745 0.63232 0.6749 0.71548 0.75342 0.78841 0.82157 0.85356 0.88519 0.91734 0.94972 0.98403 1.0219 1.0648 1.1143 1.1713 1.2359 1.3092 1.3911 1.4809 1.5776 1.6787 1.7819 1.8846 1.9842 2.0777 2.1627 2.2362 2.2969 2.3436 2.3759 2.3942 2.3994 2.3927 2.3763 2.3521 2.3222 2.2886 2.2524 2.2149 2.1772 2.1394 2.1018 2.0641 2.0259 1.9878 1.9494 1.9106 1.8711 1.8305 1.7886 1.7455 1.7008 1.6537 1.6036 1.5495 1.492 1.431 1.3664 1.2981 1.2262 1.1508 1.0736 0.99504 0.91575 0.83626 0.75657 0.67816 0.60206 0.52843 0.45712 0.38776 0.31881 0.2515 0.18511 0.11894 0.052471 -0.01492 -0.082568 -0.14848 -0.21193 -0.27229 -0.32905 -0.38303 -0.43222 -0.47628 -0.51587 -0.55188 -0.58534 -0.61763 -0.64653 -0.67227 -0.69521 -0.71576 -0.73517 -0.75286 -0.76798 -0.7812 -0.79326 -0.80474 -0.81719 -0.82831 -0.83768 -0.84538 -0.85165 -0.85731 -0.86309 -0.86791 -0.87271 -0.87846 -0.88592 -0.89619 -0.90783 -0.91942 -0.93018 -0.93939 ================================================ FILE: testData/test2.txt ================================================ -0.89094 -0.86099 -0.82438 -0.78214 -0.73573 -0.68691 -0.63754 -0.58937 -0.54342 -0.50044 -0.46082 -0.42469 -0.3924 -0.36389 -0.33906 -0.31795 -0.30056 -0.28692 -0.27727 -0.27105 -0.26777 -0.26678 -0.26742 -0.26927 -0.27202 -0.27529 -0.27898 -0.2832 -0.28814 -0.29431 -0.30185 -0.31086 -0.32135 -0.33326 -0.3465 -0.36103 -0.37659 -0.39297 -0.40995 -0.42731 -0.44484 -0.46226 -0.47921 -0.49534 -0.51031 -0.52382 -0.53567 -0.54568 -0.55375 -0.55984 -0.56397 -0.56617 -0.56653 -0.56511 -0.56201 -0.55736 -0.55133 -0.54419 -0.53617 -0.52758 -0.51876 -0.51004 -0.50174 -0.49418 -0.48731 -0.48128 -0.47619 -0.4721 -0.46921 -0.4674 -0.46649 -0.46659 -0.46785 -0.47045 -0.4749 -0.48081 -0.48822 -0.49726 -0.50805 -0.52086 -0.53596 -0.55266 -0.57081 -0.59021 -0.61063 -0.63238 -0.65484 -0.67722 -0.69907 -0.72004 -0.73987 -0.75965 -0.77816 -0.79527 -0.8109 -0.82509 -0.83844 -0.85159 -0.86373 -0.87474 -0.88447 -0.8929 -0.90125 -0.90911 -0.91606 -0.92197 -0.92677 -0.93071 -0.93528 -0.93931 -0.9426 -0.94494 -0.94622 -0.94735 -0.94879 -0.94965 -0.94971 -0.94878 -0.94679 -0.94571 -0.94428 -0.94176 -0.93756 -0.9311 -0.92258 -0.91342 -0.90142 -0.88573 -0.86549 -0.83998 -0.81054 -0.77682 -0.73745 -0.692 -0.64033 -0.58278 -0.52295 -0.45966 -0.39357 -0.32536 -0.2557 -0.18627 -0.11888 -0.052529 0.012911 0.077684 0.14195 0.2039 0.26391 0.3225 0.37976 0.43566 0.48977 0.53999 0.58745 0.63232 0.6749 0.71548 0.75342 0.78841 0.82157 0.85356 0.88519 0.91734 0.94972 0.98403 1.0219 1.0648 1.1143 1.1713 1.2359 1.3092 1.3911 1.4809 1.5776 1.6787 1.7819 1.8846 1.9842 2.0777 2.1627 2.2362 2.2969 2.3436 2.3759 2.3942 2.3994 2.3927 2.3763 2.3521 2.3222 2.2886 2.2524 2.2149 2.1772 2.1394 2.1018 2.0641 2.0259 1.9878 1.9494 1.9106 1.8711 1.8305 1.7886 1.7455 1.7008 1.6537 1.6036 1.5495 1.492 1.431 1.3664 1.2981 1.2262 1.1508 1.0736 0.99504 0.91575 0.83626 0.75657 0.67816 0.60206 0.52843 0.45712 0.38776 0.31881 0.2515 0.18511 0.11894 0.052471 -0.01492 -0.082568 -0.14848 -0.21193 -0.27229 -0.32905 -0.38303 -0.43222 -0.47628 -0.51587 -0.55188 -0.58534 -0.61763 -0.64653 -0.67227 -0.69521 -0.71576 -0.73517 -0.75286 -0.76798 -0.7812 -0.79326 -0.80474 -0.81719 -0.82831 -0.83768 -0.84538 -0.85165 -0.85731 -0.86309 -0.86791 -0.87271 -0.87846 -0.88592 -0.89619 -0.90783 -0.91942 -0.93018 -0.93939 ================================================ FILE: testData/test2_output.txt ================================================ -0.23703703703704, DN_OutlierInclude_n_001_mdrmd, 0.248000 0.40740740740741, DN_OutlierInclude_p_001_mdrmd, 0.342000 -0.61479911484527, DN_HistogramMode_5, 0.005000 -0.78225446555221, DN_HistogramMode_10, 0.003000 7.13507860878856, CO_Embed2_Dist_tau_d_expfit_meandiff, 0.283000 32.50260547693646, CO_f1ecac, 0.197000 77.00000000000000, CO_FirstMin_ac, 0.315000 1.00638907799376, CO_HistogramAMI_even_2_5, 0.017000 0.00001782472612, CO_trev_1_num, 0.008000 0.84782608695652, FC_LocalSimple_mean1_tauresrat, 0.522000 0.08029384289851, FC_LocalSimple_mean3_stderr, 0.010000 40.00000000000000, IN_AutoMutualInfoStats_40_gaussian_fmmi, 0.114000 0.31970260223048, MD_hrv_classic_pnn40, 0.002000 83.00000000000000, SB_BinaryStats_diff_longstretch0, 0.003000 88.00000000000000, SB_BinaryStats_mean_longstretch1, 0.003000 1.21058781724385, SB_MotifThree_quantile_hh, 0.047000 0.29545454545455, SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1, 0.193000 0.75000000000000, SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1, 0.075000 0.99313877887425, SP_Summaries_welch_rect_area_5_1, 0.077000 0.03681553890926, SP_Summaries_welch_rect_centroid, 0.074000 0.08000000000000, SB_TransitionMatrix_3ac_sumdiagcov, 0.309000 0.00000000000000, PD_PeriodicityWang_th0_01, 0.135000 ================================================ FILE: testData/testInf.txt ================================================ inf -0.42469 -0.3924 -0.36389 -0.33906 -0.31795 -0.30056 -0.28692 -0.27727 -0.27105 -0.26777 -0.26678 -0.26742 -0.26927 -0.27202 -0.27529 -0.27898 -0.2832 -0.28814 -0.29431 -0.30185 -0.31086 -0.32135 -0.33326 -0.3465 -0.36103 -0.37659 -0.39297 -0.40995 -0.42731 -0.44484 -0.46226 -0.47921 -0.49534 -0.51031 -0.52382 -0.53567 -0.54568 -0.55375 -0.55984 -0.56397 -0.56617 -0.56653 -0.56511 -0.56201 -0.55736 -0.55133 -0.54419 -0.53617 -0.52758 -0.51876 -0.51004 -0.50174 -0.49418 -0.48731 -0.48128 -0.47619 -0.4721 -0.46921 -0.4674 -0.46649 -0.46659 -0.46785 -0.47045 -0.4749 -0.48081 -0.48822 -0.49726 -0.50805 -0.52086 -0.53596 -0.55266 -0.57081 -0.59021 -0.61063 -0.63238 -0.65484 -0.67722 -0.69907 -0.72004 -0.73987 -0.75965 -0.77816 -0.79527 -0.8109 -0.82509 -0.83844 -0.85159 -0.86373 -0.87474 -0.88447 -0.8929 -0.90125 -0.90911 -0.91606 -0.92197 -0.92677 -0.93071 -0.93528 -0.93931 -0.9426 -0.94494 -0.94622 -0.94735 -0.94879 -0.94965 -0.94971 -0.94878 -0.94679 -0.94571 -0.94428 -0.94176 -0.93756 -0.9311 -0.92258 -0.91342 -0.90142 -0.88573 -0.86549 -0.83998 -0.81054 -0.77682 -0.73745 -0.692 -0.64033 -0.58278 -0.52295 -0.45966 -0.39357 -0.32536 -0.2557 -0.18627 -0.11888 -0.052529 0.012911 0.077684 0.14195 0.2039 0.26391 0.3225 0.37976 0.43566 0.48977 0.53999 0.58745 0.63232 0.6749 0.71548 0.75342 0.78841 0.82157 0.85356 0.88519 0.91734 0.94972 0.98403 1.0219 1.0648 1.1143 1.1713 1.2359 1.3092 1.3911 1.4809 1.5776 1.6787 1.7819 1.8846 1.9842 2.0777 2.1627 2.2362 2.2969 2.3436 2.3759 2.3942 2.3994 2.3927 2.3763 2.3521 2.3222 2.2886 2.2524 2.2149 2.1772 2.1394 2.1018 2.0641 2.0259 1.9878 1.9494 1.9106 1.8711 1.8305 1.7886 1.7455 1.7008 1.6537 1.6036 1.5495 1.492 1.431 1.3664 1.2981 1.2262 1.1508 1.0736 0.99504 0.91575 0.83626 0.75657 0.67816 0.60206 0.52843 0.45712 0.38776 0.31881 0.2515 0.18511 0.11894 0.052471 -0.01492 -0.082568 -0.14848 -0.21193 -0.27229 -0.32905 -0.38303 -0.43222 -0.47628 -0.51587 -0.55188 -0.58534 -0.61763 -0.64653 -0.67227 -0.69521 -0.71576 -0.73517 -0.75286 -0.76798 -0.7812 -0.79326 -0.80474 -0.81719 -0.82831 -0.83768 -0.84538 -0.85165 -0.85731 -0.86309 -0.86791 -0.87271 -0.87846 -0.88592 -0.89619 -0.90783 -0.91942 -0.93018 -0.93939 ================================================ FILE: testData/testInfMinus.txt ================================================ -inf -0.42469 -0.3924 -0.36389 -0.33906 -0.31795 -0.30056 -0.28692 -0.27727 -0.27105 -0.26777 -0.26678 -0.26742 -0.26927 -0.27202 -0.27529 -0.27898 -0.2832 -0.28814 -0.29431 -0.30185 -0.31086 -0.32135 -0.33326 -0.3465 -0.36103 -0.37659 -0.39297 -0.40995 -0.42731 -0.44484 -0.46226 -0.47921 -0.49534 -0.51031 -0.52382 -0.53567 -0.54568 -0.55375 -0.55984 -0.56397 -0.56617 -0.56653 -0.56511 -0.56201 -0.55736 -0.55133 -0.54419 -0.53617 -0.52758 -0.51876 -0.51004 -0.50174 -0.49418 -0.48731 -0.48128 -0.47619 -0.4721 -0.46921 -0.4674 -0.46649 -0.46659 -0.46785 -0.47045 -0.4749 -0.48081 -0.48822 -0.49726 -0.50805 -0.52086 -0.53596 -0.55266 -0.57081 -0.59021 -0.61063 -0.63238 -0.65484 -0.67722 -0.69907 -0.72004 -0.73987 -0.75965 -0.77816 -0.79527 -0.8109 -0.82509 -0.83844 -0.85159 -0.86373 -0.87474 -0.88447 -0.8929 -0.90125 -0.90911 -0.91606 -0.92197 -0.92677 -0.93071 -0.93528 -0.93931 -0.9426 -0.94494 -0.94622 -0.94735 -0.94879 -0.94965 -0.94971 -0.94878 -0.94679 -0.94571 -0.94428 -0.94176 -0.93756 -0.9311 -0.92258 -0.91342 -0.90142 -0.88573 -0.86549 -0.83998 -0.81054 -0.77682 -0.73745 -0.692 -0.64033 -0.58278 -0.52295 -0.45966 -0.39357 -0.32536 -0.2557 -0.18627 -0.11888 -0.052529 0.012911 0.077684 0.14195 0.2039 0.26391 0.3225 0.37976 0.43566 0.48977 0.53999 0.58745 0.63232 0.6749 0.71548 0.75342 0.78841 0.82157 0.85356 0.88519 0.91734 0.94972 0.98403 1.0219 1.0648 1.1143 1.1713 1.2359 1.3092 1.3911 1.4809 1.5776 1.6787 1.7819 1.8846 1.9842 2.0777 2.1627 2.2362 2.2969 2.3436 2.3759 2.3942 2.3994 2.3927 2.3763 2.3521 2.3222 2.2886 2.2524 2.2149 2.1772 2.1394 2.1018 2.0641 2.0259 1.9878 1.9494 1.9106 1.8711 1.8305 1.7886 1.7455 1.7008 1.6537 1.6036 1.5495 1.492 1.431 1.3664 1.2981 1.2262 1.1508 1.0736 0.99504 0.91575 0.83626 0.75657 0.67816 0.60206 0.52843 0.45712 0.38776 0.31881 0.2515 0.18511 0.11894 0.052471 -0.01492 -0.082568 -0.14848 -0.21193 -0.27229 -0.32905 -0.38303 -0.43222 -0.47628 -0.51587 -0.55188 -0.58534 -0.61763 -0.64653 -0.67227 -0.69521 -0.71576 -0.73517 -0.75286 -0.76798 -0.7812 -0.79326 -0.80474 -0.81719 -0.82831 -0.83768 -0.84538 -0.85165 -0.85731 -0.86309 -0.86791 -0.87271 -0.87846 -0.88592 -0.89619 -0.90783 -0.91942 -0.93018 -0.93939 ================================================ FILE: testData/testNaN.txt ================================================ nan -0.42469 -0.3924 -0.36389 -0.33906 -0.31795 -0.30056 -0.28692 -0.27727 -0.27105 -0.26777 -0.26678 -0.26742 -0.26927 -0.27202 -0.27529 -0.27898 -0.2832 -0.28814 -0.29431 -0.30185 -0.31086 -0.32135 -0.33326 -0.3465 -0.36103 -0.37659 -0.39297 -0.40995 -0.42731 -0.44484 -0.46226 -0.47921 -0.49534 -0.51031 -0.52382 -0.53567 -0.54568 -0.55375 -0.55984 -0.56397 -0.56617 -0.56653 -0.56511 -0.56201 -0.55736 -0.55133 -0.54419 -0.53617 -0.52758 -0.51876 -0.51004 -0.50174 -0.49418 -0.48731 -0.48128 -0.47619 -0.4721 -0.46921 -0.4674 -0.46649 -0.46659 -0.46785 -0.47045 -0.4749 -0.48081 -0.48822 -0.49726 -0.50805 -0.52086 -0.53596 -0.55266 -0.57081 -0.59021 -0.61063 -0.63238 -0.65484 -0.67722 -0.69907 -0.72004 -0.73987 -0.75965 -0.77816 -0.79527 -0.8109 -0.82509 -0.83844 -0.85159 -0.86373 -0.87474 -0.88447 -0.8929 -0.90125 -0.90911 -0.91606 -0.92197 -0.92677 -0.93071 -0.93528 -0.93931 -0.9426 -0.94494 -0.94622 -0.94735 -0.94879 -0.94965 -0.94971 -0.94878 -0.94679 -0.94571 -0.94428 -0.94176 -0.93756 -0.9311 -0.92258 -0.91342 -0.90142 -0.88573 -0.86549 -0.83998 -0.81054 -0.77682 -0.73745 -0.692 -0.64033 -0.58278 -0.52295 -0.45966 -0.39357 -0.32536 -0.2557 -0.18627 -0.11888 -0.052529 0.012911 0.077684 0.14195 0.2039 0.26391 0.3225 0.37976 0.43566 0.48977 0.53999 0.58745 0.63232 0.6749 0.71548 0.75342 0.78841 0.82157 0.85356 0.88519 0.91734 0.94972 0.98403 1.0219 1.0648 1.1143 1.1713 1.2359 1.3092 1.3911 1.4809 1.5776 1.6787 1.7819 1.8846 1.9842 2.0777 2.1627 2.2362 2.2969 2.3436 2.3759 2.3942 2.3994 2.3927 2.3763 2.3521 2.3222 2.2886 2.2524 2.2149 2.1772 2.1394 2.1018 2.0641 2.0259 1.9878 1.9494 1.9106 1.8711 1.8305 1.7886 1.7455 1.7008 1.6537 1.6036 1.5495 1.492 1.431 1.3664 1.2981 1.2262 1.1508 1.0736 0.99504 0.91575 0.83626 0.75657 0.67816 0.60206 0.52843 0.45712 0.38776 0.31881 0.2515 0.18511 0.11894 0.052471 -0.01492 -0.082568 -0.14848 -0.21193 -0.27229 -0.32905 -0.38303 -0.43222 -0.47628 -0.51587 -0.55188 -0.58534 -0.61763 -0.64653 -0.67227 -0.69521 -0.71576 -0.73517 -0.75286 -0.76798 -0.7812 -0.79326 -0.80474 -0.81719 -0.82831 -0.83768 -0.84538 -0.85165 -0.85731 -0.86309 -0.86791 -0.87271 -0.87846 -0.88592 -0.89619 -0.90783 -0.91942 -0.93018 -0.93939 ================================================ FILE: testData/testShort.txt ================================================ -0.89094 -0.86099 -0.82438 -0.78214 -0.73573 -0.68691 -0.63754 -0.58937 -0.54342 -0.50044 -0.46082 -0.42469 ================================================ FILE: testData/testShort_output.txt ================================================ -0.58333333333333, DN_OutlierInclude_n_001_mdrmd, 0.019000 0.75000000000000, DN_OutlierInclude_p_001_mdrmd, 0.017000 0.02269949495805, DN_HistogramMode_5, 0.001000 0.02269949495805, DN_HistogramMode_10, 0.001000 0.51152503131790, CO_Embed2_Dist_tau_d_expfit_meandiff, 0.012000 2.67524184613158, CO_f1ecac, 0.004000 8.00000000000000, CO_FirstMin_ac, 0.004000 1.36615884756920, CO_HistogramAMI_even_2_5, 0.003000 0.01964378196445, CO_trev_1_num, 0.001000 0.60000000000000, FC_LocalSimple_mean1_tauresrat, 0.008000 0.05070841167817, FC_LocalSimple_mean3_stderr, 0.000000 6.00000000000000, IN_AutoMutualInfoStats_40_gaussian_fmmi, 0.002000 1.00000000000000, MD_hrv_classic_pnn40, 0.000000 1.00000000000000, SB_BinaryStats_diff_longstretch0, 0.001000 5.00000000000000, SB_BinaryStats_mean_longstretch1, 0.000000 1.49903067297901, SB_MotifThree_quantile_hh, 0.004000 0.00000000000000, SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1, 0.007000 0.00000000000000, SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1, 0.006000 0.00000000000000, SP_Summaries_welch_rect_area_5_1, 0.004000 0.39269908169875, SP_Summaries_welch_rect_centroid, 0.003000 0.16666666666667, SB_TransitionMatrix_3ac_sumdiagcov, 0.006000 0.00000000000000, PD_PeriodicityWang_th0_01, 0.013000 ================================================ FILE: testData/testSinusoid.txt ================================================ 0.07278102 0.04887893 0.08751903 0.13499968 0.12611472 0.32822557 0.07535813 0.24774287 0.12878436 0.34140028 0.15010170 0.26043849 0.41951105 0.23625629 0.15366643 0.21353631 0.27866994 0.26928280 0.24791033 0.46969495 0.40362597 0.49709404 0.34962158 0.51007852 0.23945292 0.43049607 0.49740328 0.33662590 0.55609625 0.51493106 0.54345507 0.47709771 0.55234106 0.42275539 0.40052568 0.43661371 0.52763128 0.61058967 0.45805922 0.50095473 0.64803553 0.58303119 0.70511679 0.47798046 0.67410219 0.63772402 0.51863295 0.59562197 0.58150174 0.65045736 0.71958237 0.51969788 0.74331280 0.75785924 0.62048786 0.65170807 0.70285796 0.74987947 0.77076486 0.78372627 0.68138110 0.70165821 0.86793856 0.76103617 0.85211206 0.68809000 0.79981394 0.79749449 0.91783356 0.66230799 0.79436735 0.80831067 0.68643447 0.93826958 0.93960459 0.81333566 0.92343823 0.74067475 0.88922420 0.78854038 0.85105295 0.97748703 0.79000731 0.82908686 0.88963149 0.85262402 0.99738831 1.06057521 0.81845315 0.84813568 0.99399790 0.90214524 1.08771309 1.09331161 1.00066752 1.07144517 0.93975659 1.01446495 1.12606836 1.00386920 1.12154856 1.06293481 0.99731958 1.04900832 1.12869529 0.92704425 0.99096536 1.17485310 1.00266329 1.08428386 1.16161180 1.19431322 1.09604943 0.93694312 0.91946771 1.09819131 1.08694642 1.20934000 1.14843765 1.12712380 1.08903308 1.01358429 1.22769749 1.10455001 0.95486505 1.15787896 1.10800519 0.97281002 1.22502673 1.05989574 1.03246854 1.00036954 1.06199191 1.03967807 1.16908369 0.99557140 1.06049402 1.06445413 1.24587341 1.11699992 1.21222397 1.16808901 1.22363154 1.02428375 1.28502751 1.24729199 1.00906231 1.13478490 1.09357683 1.18579929 1.06658474 1.17211796 1.17965704 1.17913167 1.13405419 1.01041080 1.15408617 1.12231873 1.03237146 1.13777830 1.13483843 1.16457374 1.24041104 1.20850300 1.25927703 1.01252267 1.06192838 1.13297595 1.28160328 1.22991726 1.12722719 1.09035526 1.00661836 1.20962543 1.13775754 1.04396357 1.11031238 1.03083156 1.20370498 1.08657617 1.25639297 0.97667872 1.21782590 1.15457168 1.12560695 1.15642749 1.17646014 0.98391809 1.21584837 0.95379426 1.03459088 0.99699439 1.21753375 0.95663118 1.10694298 1.12010508 1.12059230 1.18075741 0.93422371 1.15846991 1.06797417 1.11339573 0.96451466 1.05938973 1.10268473 1.17429274 1.01607000 0.90358341 0.89033502 1.05704973 1.10206309 1.06547523 0.95653284 1.13172284 0.99838753 1.12304270 0.85346215 0.88789458 1.05261229 1.08859724 1.04326160 0.89123133 0.84211919 1.04485338 1.01977230 0.85932265 0.84009587 0.86166192 1.00774925 0.99898523 0.91691007 0.91055417 0.81803693 0.93512446 0.95734218 0.84395007 0.83827545 0.83697646 0.77378674 0.88541582 0.94656254 0.94061336 0.88474028 0.73119420 0.85232635 0.67731390 0.66708088 0.67950441 0.65809389 0.78196661 0.62048065 0.83712878 0.79920154 0.85192956 0.71374781 0.75414859 0.81639248 0.70252989 0.61719646 0.81683160 0.52642903 0.60478022 0.79016573 0.59907639 0.57356750 0.50830426 0.73792098 0.49494913 0.54501001 0.70564305 0.57727451 0.60290441 0.58415406 0.60954566 0.39968448 0.54002580 0.38202089 0.61124254 0.45576021 0.59840675 0.40880902 0.49999671 0.59738103 0.32091117 0.31323465 0.29366342 0.48232948 0.44785461 0.29282836 0.48782039 0.42460451 0.25059200 0.24056730 0.25081952 0.43689738 0.21814218 0.25195691 0.24384620 0.19233698 0.40851854 0.35057994 0.35133583 0.31645244 0.26624236 0.19933443 0.28999750 0.11677180 0.11587674 0.06748312 0.34085729 0.33269253 0.06874555 0.16181398 0.20860059 0.08864832 0.21795374 0.14902911 0.09993425 0.04176031 0.17773238 0.21113875 0.15017920 0.04372201 0.19320252 -0.02162036 0.05175384 0.16829561 -0.04773050 -0.06294048 0.13043864 -0.13717099 -0.07779232 0.00001264 -0.12630492 -0.00634321 0.03260911 -0.06616476 -0.03118288 0.00263117 -0.17584837 -0.07528942 -0.23145743 -0.12009497 -0.03307351 -0.01776128 -0.15407313 -0.22977102 -0.12677991 -0.05679555 -0.18844944 -0.05852578 -0.30094642 -0.33608546 -0.28950859 -0.26902536 -0.27092146 -0.31286309 -0.20726966 -0.39693642 -0.31290430 -0.35396620 -0.35951672 -0.42869758 -0.29107176 -0.39320899 -0.44022016 -0.49529977 -0.41907992 -0.34752604 -0.26005813 -0.51716011 -0.26687391 -0.50739882 -0.30491823 -0.32318677 -0.29619729 -0.53854710 -0.43643741 -0.47442968 -0.55184610 -0.43930281 -0.43787146 -0.56322010 -0.47932837 -0.34624300 -0.50365059 -0.44972451 -0.54225544 -0.66267791 -0.59262310 -0.44733364 -0.59104038 -0.67715151 -0.55589948 -0.60619555 -0.50134427 -0.57263631 -0.49549933 -0.49850579 -0.69338688 -0.71969446 -0.51700204 -0.57835385 -0.77123239 -0.51354952 -0.63391274 -0.63127917 -0.61873412 -0.57848688 -0.55588399 -0.70341658 -0.79858958 -0.60944718 -0.73555425 -0.58868454 -0.73446671 -0.60280882 -0.80352239 -0.82274094 -0.60266459 -0.85835203 -0.67041871 -0.66107415 -0.75473748 -0.77653213 -0.60109213 -0.77970738 -0.77167545 -0.86092489 -0.81430192 -0.82194736 -0.65177785 -0.84989090 -0.83457216 -0.80880012 -0.72264931 -0.89545958 -0.68055866 -0.92031874 -0.80995987 -0.94248537 -0.72866761 -0.74754521 -0.89603881 -0.75915952 -0.79858526 -0.71311494 -0.80319769 -0.70258688 -0.84951801 -0.87009161 -0.83289291 -0.90476161 -0.70466241 -0.84515074 -0.91064150 -0.85904572 -0.77912080 -0.87055041 -0.93796779 -0.73681567 -0.81950246 -0.88366154 -0.93009958 -0.93168283 -0.84138471 -0.86860120 -0.77671053 -0.97834063 -0.74554935 -0.79595919 -0.95900169 -0.74245038 -0.93989469 -0.81741686 -0.83637929 -0.95016940 -0.99664502 -0.76626970 -0.76755351 -0.86984380 -0.97819587 -0.81849142 -0.94084522 -0.77328556 -0.83025922 -0.91320597 -0.71248805 -0.75852777 -0.71815936 -0.96181316 -0.92547994 -0.75740433 -0.76740155 -0.74111038 -0.82133204 -0.84185165 -0.78363024 -0.70767379 -0.76047377 -0.80184666 -0.86639513 -0.74186891 -0.83550094 -0.77650828 -0.67719038 -0.68730442 -0.66709616 -0.65148765 -0.68491756 -0.92540733 -0.92106147 -0.89182983 -0.83584226 -0.90311945 -0.77854120 -0.79916417 -0.73470434 -0.61479695 -0.79854574 -0.78202922 -0.62088136 -0.77176477 -0.82756762 -0.71167263 -0.60193755 -0.73847669 -0.63981441 -0.65481649 -0.70265303 -0.69018206 -0.54177027 -0.79596498 -0.73131554 -0.67533046 -0.62724878 -0.53423706 -0.65072454 -0.65407741 -0.55521719 -0.63239135 -0.50813082 -0.61996332 -0.60394749 -0.60053622 -0.67123668 -0.70764953 -0.70626477 -0.45305439 -0.64264132 -0.44706160 -0.48489794 -0.42938287 -0.40256535 -0.63472995 -0.55106981 -0.36760721 -0.46080787 -0.37772774 -0.49432148 -0.62703872 -0.43661544 -0.54630150 -0.44948891 -0.38224974 -0.40949084 -0.40711473 -0.44544493 -0.49401668 -0.43031689 -0.54763231 -0.35966459 -0.24648971 -0.49676617 -0.50618828 -0.24240854 -0.42555947 -0.48828021 -0.23774239 -0.43128417 -0.20064225 -0.42711087 -0.34103202 -0.25980535 -0.25326472 -0.21945949 -0.21625871 -0.27151789 -0.35042260 -0.15755375 -0.30134063 -0.16944554 -0.09804134 -0.32057711 -0.04486161 -0.31761683 -0.06696720 -0.05737655 -0.28360449 -0.12523721 0.00353545 -0.17335806 -0.01821745 -0.07006936 -0.00390929 0.00867772 -0.20646761 -0.12661458 -0.00575308 -0.04508931 0.10969317 0.05222610 0.00789033 -0.06289766 -0.06586361 0.13317723 0.01116626 0.13185238 -0.07350111 0.16482753 -0.07480070 0.19662694 0.20683738 0.10407157 -0.00711203 0.02015901 0.18864905 0.23622300 0.00726484 0.23416625 0.30394755 0.12967263 0.22827949 0.14969934 0.12172555 0.30262518 0.29366616 0.17035735 0.27139295 0.23291343 0.14416982 0.13368326 0.28373201 0.22976795 0.25809993 0.25224699 0.22716580 0.30550895 0.40484139 0.26644645 0.41501793 0.35779477 0.36459600 0.29688826 0.31196170 0.44858658 0.35399618 0.45080186 0.57591087 0.51636511 0.51530726 0.60884213 0.56308274 0.52222197 0.63369204 0.37653634 0.44857421 0.67324439 0.61814453 0.53829229 0.60911979 0.53905378 0.53710016 0.49607625 0.55597305 0.45894440 0.60064781 0.56782481 0.76938118 0.65202788 0.74800444 0.62520152 0.65000677 0.76786105 0.82584570 0.69413190 0.82298784 0.77541796 0.73223968 0.86088703 0.82578959 0.87445074 0.78854131 0.71651961 0.75356978 0.89205307 0.63076919 0.68108546 0.78324853 0.81231236 0.67489391 0.86190174 0.93882284 0.71219443 0.81794106 0.77791397 0.99658527 0.89073532 0.79125799 0.76187166 0.89247051 0.98411912 0.99361515 0.99917894 0.81687514 0.92559640 1.03118827 0.81136296 1.03824815 1.05747757 0.85902740 0.82280532 0.94793990 1.06206678 0.95817863 0.94721186 0.97954275 0.87190598 0.87943129 1.10627602 1.03132168 0.93524530 1.12022816 0.88326675 1.00812002 1.09232961 0.98215176 1.00551522 1.04785192 1.16254847 1.13221629 0.92385884 0.99093408 1.02526910 1.17492820 1.04549129 0.99535120 1.10647676 1.07470146 1.20405103 1.21841275 1.18678542 1.15741732 1.17094158 1.22102433 0.97372421 1.05787108 0.96124800 1.21112991 1.11758933 1.07776840 1.03837575 1.13320047 1.06186627 0.99770442 1.00475901 1.00174633 1.10606802 1.02191775 1.11949009 1.25785015 1.09574424 1.02709132 1.16305742 1.25602094 1.09917127 1.00816328 1.03917753 1.02024246 1.22011185 1.13550088 1.19950776 1.20919650 1.17111962 1.18851026 1.26332125 1.19868741 1.26249579 1.13991665 1.04175222 1.01938168 1.21270410 1.09021739 1.19846119 1.19202895 1.15470843 1.20891742 1.14472060 1.13847000 1.14011525 1.27015091 1.10463831 1.02139412 1.05667579 1.18822096 1.23262592 1.26989656 1.04130951 1.20266940 1.14750757 1.09077528 1.12041802 1.11351855 1.15755867 1.18248668 1.04709161 0.98042423 1.19827002 1.06420116 1.17666647 0.99454129 0.97010039 1.20530727 1.19303944 1.22635326 1.18188062 0.92976392 1.07810998 1.20990322 1.05974287 1.16422549 0.91887947 1.18962606 1.16564055 1.05347800 1.00892311 0.97603470 1.08600772 0.86890974 0.97196704 1.13140447 1.01330727 0.98620897 0.98759924 0.92584064 1.11282853 1.11652045 0.97025440 1.10814380 0.94122032 0.92629938 0.85639160 0.84426283 1.02989645 0.99176548 0.92632487 1.00967544 0.90798752 0.91341227 0.80513293 0.91074329 0.77040226 0.73634379 0.91870047 0.88923594 0.76545421 0.81426079 0.87409933 0.84440086 0.70869614 0.71372873 0.65574957 0.77331345 0.78676059 0.68046170 0.82477553 0.62226050 0.64488575 0.88665858 0.88575493 0.59419155 0.72494171 0.82739607 0.63318771 0.80229530 0.78772580 0.72392020 0.52742604 0.63214539 0.78097172 0.70512636 0.60598854 0.67319952 0.54781711 0.63743584 0.75165961 0.70312893 0.52429611 0.63499475 0.52864639 0.70819652 0.42818262 0.46890644 0.62800722 0.40068027 0.52544210 0.59692877 0.56902913 0.38048661 0.45992774 0.42421247 0.45315460 0.47630240 0.33426910 0.55254354 0.46339151 0.31057684 0.42180372 0.52182575 0.46755761 0.42859606 0.35299628 0.28144519 0.36432915 0.25835948 0.26967996 0.43727397 0.41972673 0.38264954 0.41211323 0.17810641 0.26978846 0.29268794 0.36859083 0.28386692 0.19146614 0.28673494 0.30004103 0.22486644 0.06027007 0.30148283 0.03085677 0.16288543 0.03043397 0.09882145 0.21863039 0.03801402 0.22012017 0.15860006 0.04826872 -0.00047524 -0.00926279 0.13509487 -0.09006942 0.09061931 0.06118840 0.08919506 0.14846456 -0.03942542 -0.08640967 0.08891408 0.05766402 -0.05564804 -0.17649604 -0.04428370 -0.16710793 -0.07355204 -0.13626173 -0.15802521 -0.04410111 -0.11702877 -0.04417706 -0.22960452 -0.09707314 -0.29428191 -0.07916748 -0.12540827 -0.05460294 -0.32033111 -0.08462519 -0.21349322 -0.19129384 -0.29019176 -0.37097658 -0.14820889 -0.36916499 -0.31046601 -0.24394085 -0.14039618 -0.29341801 -0.16038253 -0.39844444 -0.35582547 -0.27503114 -0.47333585 -0.27710665 -0.38391191 -0.27521272 -0.41325041 -0.43988299 -0.24820579 -0.33693021 -0.43673761 -0.53935562 -0.35677213 -0.39408544 -0.57120369 -0.56522341 -0.31485645 -0.46819402 -0.61834655 -0.61669548 -0.59829382 -0.38016063 -0.51603904 -0.49504460 -0.52241495 -0.65779937 -0.41615639 -0.60612756 -0.61916064 -0.52872398 -0.57125537 -0.61049121 -0.53119454 -0.45323831 -0.55531797 -0.66326644 -0.69316223 -0.62949904 -0.75951074 -0.51120028 -0.59732028 -0.72548457 -0.63672292 -0.78260708 -0.54607468 -0.67774657 -0.65203922 -0.65211708 -0.62370797 -0.72198125 -0.81541123 -0.70737576 -0.83524454 -0.63335233 -0.84857523 -0.57876266 -0.64729802 -0.59366162 -0.72568656 -0.81213563 -0.81104035 -0.66587165 -0.60000567 -0.79535158 -0.68077053 -0.87778724 -0.73577105 -0.78969741 -0.70356002 -0.84822975 -0.90185482 -0.79862957 -0.74542436 -0.90126943 -0.80837462 -0.75180732 -0.70251880 -0.86125127 -0.83592594 -0.69423063 -0.75209524 -0.89238024 -0.73956873 -0.88272015 -0.88914885 -0.97283348 -0.86444037 -0.84786408 -0.88964669 -0.89557235 -0.91187150 -0.70531878 -0.72986564 -0.87025428 -0.84699814 -0.82262708 -0.84644291 -0.91348872 -0.69851421 -0.94123805 -0.73864860 -0.98806101 -0.89886874 -0.77433757 -0.80605736 -0.94890161 -0.71421719 -0.83700339 -0.92456616 -0.82632426 -0.72505873 -0.73072854 -0.85426136 -0.86569729 -0.90439890 -0.98063755 -0.77030073 -0.95596096 -0.88777595 -0.87469923 -0.72661273 -0.98460660 -0.73636451 -0.90167883 -0.91140966 -0.83831247 -0.76433089 -0.92037396 -0.91429487 -0.68419840 -0.79695134 -0.88132683 -0.67996560 -0.69901705 -0.90823511 -0.96204119 -0.74629383 -0.69665092 -0.91852688 -0.93926725 -0.76837559 -0.76330491 -0.78633980 -0.93559373 -0.72764859 -0.64691170 -0.66495302 -0.88923447 -0.81295772 -0.84276667 -0.74317538 -0.72329377 -0.81261500 -0.65907074 -0.65538645 -0.65522754 -0.77961301 -0.86395216 -0.66284079 -0.57269690 -0.81686869 -0.82649138 -0.58156224 -0.70570582 -0.58935416 -0.59653034 -0.77800121 -0.75431030 -0.80657194 -0.63441622 -0.57812927 -0.65209299 -0.79111987 -0.49628205 -0.63698905 -0.68146645 -0.72261731 -0.58073042 -0.58944313 -0.53017401 -0.70282449 -0.63517958 -0.69229189 -0.47348268 -0.62041903 -0.63226381 -0.70599078 -0.46012102 -0.54430260 -0.52493335 -0.41770494 -0.45475022 -0.46373494 -0.60300340 -0.48392849 -0.35347502 -0.45492735 -0.38339556 -0.32277741 -0.34446830 -0.53814203 -0.58389138 -0.45087110 -0.57393909 -0.42777565 -0.27628417 -0.47865588 -0.42905765 -0.40714291 -0.27884175 -0.27219561 -0.37512007 -0.38823051 -0.21596666 -0.26275342 -0.25494738 -0.18334567 -0.30552698 -0.21208371 -0.30504102 -0.17693499 -0.30552373 -0.19205612 -0.11151226 -0.23828841 -0.25709831 -0.31468164 -0.27052714 -0.32496822 -0.23631217 -0.24051502 -0.22743173 -0.07547169 -0.15161376 -0.14526363 -0.05975807 -0.24639368 -0.08523075 -0.15923719 -0.15318565 -0.07150081 0.02500558 -0.16487330 -0.01295100 0.06564053 -0.13536384 -0.09580834 -0.02650157 0.10136709 -0.00530976 -0.06274995 0.02423913 0.04624033 0.00773318 -0.10174104 0.11460793 0.06576088 0.03808343 -0.04684244 0.05123322 0.02392137 0.02468862 0.21776632 0.10166049 0.00970198 0.11614485 0.24612722 0.07321647 0.30728872 0.13937728 0.15253758 0.12485716 0.30372730 0.10452388 0.37850283 0.15090694 0.19931878 0.32945343 0.17557699 0.29676206 0.36942385 0.44155372 0.39238945 0.40755354 0.31461760 0.27407256 0.36826331 0.28749329 0.48422620 0.44010629 0.49578946 0.49874953 0.41095913 0.37269936 0.49570194 0.59504120 0.53949317 0.56688388 0.53929987 0.51550743 0.57216712 0.50468530 0.62453661 0.39469681 0.67410654 0.42238555 0.56602841 0.53196268 0.45227908 0.64647020 0.62233544 0.68208775 0.62610532 0.70839112 0.64685787 0.76581622 0.75277720 0.65230717 0.74530841 0.65915475 0.77441843 0.63100218 0.83552803 0.63451948 0.58122240 0.79300129 0.82519509 0.86068663 0.69018080 0.84132340 0.76954681 0.75496846 0.87005176 0.91718294 0.66221400 0.85959066 0.72505979 0.78177758 0.75000709 0.92671765 0.98290199 0.88647291 0.90992207 0.98554592 0.91919888 0.89038615 0.84103911 0.92399090 0.84934448 0.86934652 0.86428070 0.90072514 0.91768838 1.04620700 0.84128031 0.88715891 0.96396374 0.94387486 0.88245012 0.98357138 1.07901960 0.83955276 0.95919491 0.85779095 1.00698316 1.00521958 1.07917396 0.92392898 1.03537034 1.00192797 1.12751784 1.07237487 0.98510103 0.98781852 0.96441504 1.17860621 0.98676693 0.94919759 1.01434386 1.13263185 1.12601049 1.12851408 0.92402828 1.03828612 1.20016043 1.02885153 1.11601596 1.02967895 0.98119998 1.06346328 1.19542912 1.24754671 1.21476683 0.98419641 1.06314811 1.03536144 1.06245604 1.26494396 1.13648277 1.19908374 1.22906731 1.02868448 1.25155477 1.01407258 1.20787487 1.20487170 1.20291556 1.02922001 1.12434406 1.14456134 1.15229089 1.25217823 1.19860048 1.23795484 1.15639697 1.28451390 1.01836950 1.16134325 1.08380749 1.14390110 1.20531179 1.06245183 1.18244428 1.09777051 1.26399350 1.03947943 1.02980514 1.28633973 1.04389725 1.04311027 1.04323708 1.02256493 1.13104471 1.19430981 1.24185600 1.22826119 1.20362996 1.13012299 1.19934841 1.27251935 1.13506521 1.07298118 1.21644316 1.04835250 1.04556613 1.11242643 1.15647669 1.15280644 1.00244495 1.00014942 1.04560635 1.17814975 1.07788786 1.20016007 1.22887466 1.06484051 0.95746951 1.10975333 1.15919605 1.02737220 1.07549037 0.99032408 1.20173618 1.06067945 1.07392889 0.97409821 0.93232482 0.91726083 1.14064383 1.12172515 0.94439184 1.14953146 1.08151084 1.06841192 1.16352237 0.87147894 0.98352464 0.99803540 1.02079817 0.86534971 1.03295310 0.84505271 0.99078180 1.03162934 0.95860227 0.99163538 0.86453392 0.98806368 0.90244475 0.81317308 0.88904165 0.84829782 0.83539970 0.94338937 0.90681297 0.86725346 0.80189291 0.98732090 0.98118383 0.80111730 0.89353611 0.93567687 0.98112580 0.96332469 0.79559180 0.72157536 0.90437596 0.69199723 0.69793513 0.74940701 0.88929261 0.80204237 0.79524156 0.88925798 0.77608722 0.59855377 0.83031099 0.76201881 0.71517097 0.64349236 0.63209638 0.69062201 0.60611865 0.54404016 0.57172233 0.58992190 0.56314800 0.67681951 0.73350978 0.72082163 0.70949894 0.67240566 0.70888282 0.67644752 0.49426972 0.72209882 0.44310598 0.60108545 0.46129353 0.46070351 0.48021018 0.42838696 0.51176580 0.63559473 0.45936601 0.50690572 0.50407670 0.52702543 0.42357926 0.55118114 0.56014544 0.49964933 0.35044545 0.49415648 0.28825978 0.38708884 0.40920034 0.42738055 0.32146946 0.41527782 0.45304383 0.19377987 0.20863953 0.41622665 0.27394791 0.26092027 0.41535673 0.34276346 0.40205279 0.16786140 0.11671790 0.19325897 0.21799272 0.22900758 0.34093436 0.18581070 0.14822448 0.31645938 0.08626259 0.19756068 0.27724054 0.17931036 0.05772120 0.11731361 -0.05157430 0.20313970 0.04934071 0.00841693 0.19326763 0.03633469 -0.02550824 -0.09634605 0.04300098 -0.09563902 -0.12952339 0.01284084 -0.08508494 -0.07245700 0.02658883 0.05682845 -0.10607675 0.06830687 0.05611057 -0.17786927 -0.01890340 -0.07438873 0.00698292 -0.09755131 -0.07726185 -0.07436287 -0.19146697 -0.24104811 -0.31494127 -0.19376968 -0.15128865 -0.27048869 -0.20815531 -0.29911115 -0.29281896 -0.19615126 -0.13305844 -0.15128738 -0.35574673 -0.30805314 -0.17043369 -0.36881380 -0.16466075 -0.27783758 -0.42281826 -0.23335223 -0.29324585 -0.33471085 -0.43189081 -0.50383493 -0.45440988 -0.42457685 -0.35130914 -0.25389702 -0.49590528 -0.33919711 -0.30863724 -0.44102265 -0.54311521 -0.35555162 -0.46385423 -0.57983832 -0.35986495 -0.43981951 -0.60892228 -0.37324229 -0.64287219 -0.64898962 -0.37181560 -0.46993610 -0.57012084 -0.53909904 -0.46854728 -0.69006346 -0.49400705 -0.50837519 -0.58802275 -0.55784537 -0.63757744 -0.69481339 -0.63286503 -0.48323667 -0.69782706 -0.66373298 -0.68098347 -0.75951670 -0.63695248 -0.54697441 -0.53145186 -0.59167889 -0.69969980 -0.73095286 -0.61852187 -0.56749307 -0.55977729 -0.81819386 -0.70311144 -0.81469269 -0.78247241 -0.59824501 -0.80955177 -0.83694328 -0.71506807 -0.78852972 -0.77295476 -0.65466759 -0.64484864 -0.69691503 -0.78020270 -0.71661520 -0.84936959 -0.73243331 -0.71898598 -0.74507289 -0.82523116 -0.82345477 -0.88488874 -0.70118885 -0.79536753 -0.84005670 -0.71710652 -0.88166979 -0.70225228 -0.71363974 -0.70752898 -0.85304495 -0.85173926 -0.71081813 -0.83245932 -0.80278396 -0.76757535 -0.69001356 -0.81641836 -0.79126477 -0.81279726 -0.70766022 -0.72829447 -0.93800391 -0.93677862 -0.91867062 -0.76742256 -0.93435119 -0.70024508 -0.78317184 -0.94426922 -0.74014777 -0.72545071 -0.71031256 -0.82806903 -0.83072270 -0.94682568 -0.84585792 -0.83545766 -0.95035359 -0.85160652 -0.83897688 -0.93950759 -0.81173682 -0.99023077 -0.90182619 -0.83680195 -0.89780836 -0.81422243 -0.88523935 -0.95218319 -0.71725628 -0.79787449 -0.79095271 -0.78442981 -0.76200684 -0.73096759 -0.82677207 -0.93425878 -0.86357231 -0.72932019 -0.92197355 -0.87204980 -0.67866320 -0.72418257 -0.89678292 -0.66077997 -0.93876683 -0.82732425 -0.83065300 -0.82875663 -0.91206288 -0.81504705 -0.75488289 -0.63904076 -0.86590785 -0.82197951 -0.84456420 -0.83312784 -0.86010882 -0.90572456 -0.77362671 -0.83113057 -0.63928891 -0.73691790 -0.61676529 -0.59424239 -0.70612063 -0.84129459 -0.59417852 -0.68913395 -0.59709475 -0.72972751 -0.66969831 -0.82536650 -0.56379924 -0.64315841 -0.79890003 -0.61456707 -0.70019550 -0.78768569 -0.74295245 -0.72671471 -0.72733657 -0.57832979 -0.55680501 -0.61260617 -0.60441083 -0.57487067 -0.46191567 -0.56070379 -0.56420996 -0.46487551 -0.55959181 -0.62335494 -0.42990488 -0.57806370 -0.52250087 -0.47973765 -0.48496599 -0.61748606 -0.64947289 -0.58419483 -0.39879523 -0.48368981 -0.50448964 -0.50710436 -0.39625188 -0.42446172 -0.41544719 -0.55652655 -0.46712614 -0.43726005 -0.46807399 -0.42839175 -0.46154948 -0.32284803 -0.43246927 -0.32579120 -0.38652988 -0.30355452 -0.23248728 -0.34997382 -0.22557408 -0.42233184 -0.21706997 -0.44542614 -0.32176421 -0.44591137 -0.20106598 -0.38080277 -0.37591997 -0.36198607 -0.19992396 -0.33407296 -0.29957782 -0.14927710 -0.22016300 -0.08836193 -0.33450272 -0.21145504 -0.16139198 -0.15410273 -0.06700002 -0.26680605 -0.20506090 -0.28489005 0.00940337 -0.03641361 -0.03126012 -0.20531421 -0.13247539 -0.18214295 -0.06878002 0.03457012 -0.00837345 0.01809766 0.01327841 0.05005186 0.09907393 0.03908759 -0.08492596 0.04279817 -0.07020146 0.16247863 -0.07618871 0.01212414 0.09471324 0.07307070 0.18207542 0.10969780 0.02864749 0.18329387 0.02503509 0.18787908 0.19063884 0.07923576 0.07511106 0.08034513 0.08531518 0.11124691 0.34689495 0.07515833 0.36761165 0.09802851 0.39160847 0.19949839 0.27767500 0.38877622 0.40890431 0.20658038 0.35797246 0.45198929 0.47217860 0.22167554 0.25277431 0.43285963 0.23350353 0.24979535 0.38487161 0.50280235 0.55662211 0.26847718 0.43956464 0.54478219 0.56868613 0.55908669 0.57864993 0.54831778 0.36915253 0.49602161 0.40333934 0.61136287 0.64973609 0.43144444 0.65494852 0.51537543 0.52293673 0.49871029 0.68670615 0.65781610 0.57870780 0.66617382 0.74547241 0.52325303 0.55319409 0.68084350 0.73984922 0.76192775 0.63395212 0.55771391 0.55564668 0.64814615 0.79706700 0.62111288 0.80232103 0.76963789 0.58924046 0.82523641 0.87432049 0.75323381 0.86367111 0.66074011 0.85707331 0.91460047 0.89436955 0.72999083 0.72362500 0.82389492 0.79382291 0.82569655 0.98741435 0.87779752 0.98706765 0.85779843 0.84904938 0.95638997 0.95466869 0.87110222 0.76083947 0.77791997 0.99752801 0.96128993 0.78072241 0.94447123 0.99954334 0.82289863 0.86086479 1.04519141 0.84941850 1.07824350 1.09651299 0.82896334 0.94389243 0.88661306 1.00377768 0.87756668 0.86412068 1.13749626 1.15410651 0.97592251 1.06583412 0.89779782 0.94454063 0.89871336 1.03221650 0.94092508 1.19768591 1.03272027 1.19543048 1.13021936 1.09124787 1.08300114 1.13640744 0.93004259 1.16695464 1.21383055 0.94174057 1.19002564 1.17612890 1.24826562 1.02052198 1.23109500 1.15074288 0.99255409 1.04412515 1.19545249 1.21047826 1.00253008 1.11451366 1.04153909 1.25476980 1.07609333 1.23920079 1.06173457 1.24894399 1.04365139 1.21647653 0.99967357 1.18421792 1.16282768 1.10684023 1.05873345 1.23356806 1.04040654 1.14426904 1.00203308 1.05471620 1.14475510 1.25100723 1.04210999 1.21961151 1.20732001 1.01030125 1.14646417 1.29097766 1.03294954 1.22173194 1.18978401 1.17583045 1.14641655 1.16634013 1.12299055 1.01686654 1.08002674 1.16000801 1.18026513 1.26805641 1.28061409 1.01372326 1.18242718 1.16290257 1.12228186 1.08498119 1.11864779 1.17505324 1.25931520 0.99572479 1.20580321 1.14109752 1.23481175 0.98868334 1.04342892 0.96791743 1.10058462 1.17666915 1.02776769 1.00710151 1.03540775 1.06843007 1.15001063 1.07800862 1.03595237 1.18890614 1.20280984 1.09759274 0.94451099 1.08609080 1.01111485 1.18908589 0.97320571 1.09435601 1.03831315 0.93087972 1.07482468 0.87812159 0.91321997 0.86640608 1.11295462 1.09402932 0.87210221 0.95426106 0.86160304 0.99147752 1.09890012 0.88515053 1.09926570 0.90123934 0.85276486 0.98378851 1.06979757 0.95828013 0.78413043 0.87064430 0.80191341 0.81479268 0.75436862 1.00245582 0.96306615 0.83006013 0.96077763 0.93024586 0.88351828 0.80798147 0.79026210 0.70179139 0.77022818 0.82484892 0.79086861 0.83873145 0.79147885 0.87401365 0.65104082 0.75313788 0.78304562 0.65426794 0.77347149 0.59755217 0.74652659 0.81829347 0.70723285 0.68069178 0.58531580 0.54064282 0.75066701 0.75395267 0.59459068 0.53243859 0.60170683 0.72910132 0.72417198 0.66236919 0.74195201 0.72791237 0.46980933 0.62146459 0.56215576 0.42876514 0.66899381 0.53964503 0.61264152 0.39009553 0.44142328 0.54866976 0.38405769 0.52613342 0.44061234 0.54536606 0.50202697 0.41106401 0.37705823 0.37950118 0.54351618 0.39507040 0.38126575 0.37507387 0.51268030 0.28508606 0.47430394 0.20575751 0.29251614 0.40996771 0.27315537 0.34609393 0.28648006 0.14372914 0.31049729 0.30132295 0.30574510 0.20379238 0.23901219 0.29159173 0.33742934 0.07762783 0.08063486 0.23607180 0.26036481 0.31753468 0.04874578 0.11049173 0.19401772 0.09387714 0.23019013 0.04875137 -0.00878950 0.14297770 -0.00802154 0.18178482 0.13661263 0.02712338 -0.10856728 -0.07373269 -0.04634488 0.12332182 0.03207299 -0.06182766 -0.08276230 -0.04730470 0.08339685 0.07998817 -0.05574868 -0.02883405 -0.01107987 -0.22941295 -0.07381118 -0.24201007 -0.13886488 -0.13493134 -0.27806303 -0.27490052 -0.02677771 -0.15323323 -0.21291727 -0.22322019 -0.29640654 -0.30631647 -0.25530372 -0.26906376 -0.14391748 -0.24233841 -0.25811628 -0.36733567 -0.14990907 -0.22253278 -0.18338312 -0.24597225 -0.15668686 -0.16682313 -0.39456625 -0.29104604 -0.26870179 -0.34643196 -0.24959352 -0.45587505 -0.48446456 -0.52937559 -0.49277887 -0.38681459 -0.40221618 -0.44812938 -0.47874672 -0.57903334 -0.34364356 -0.40474824 -0.46976983 -0.53898335 -0.37906977 -0.38070824 -0.37999373 -0.50316326 -0.35975261 -0.40614753 -0.64244884 -0.60215961 -0.43552665 -0.56633985 -0.55541654 -0.41700155 -0.42004279 -0.48696994 -0.55113468 -0.45558426 -0.58852602 -0.69407228 -0.65272257 -0.66816186 -0.59609825 -0.74976351 -0.75565495 -0.73257705 -0.50456681 -0.55157874 -0.58779605 -0.51580648 -0.51321882 -0.52229586 -0.77920991 -0.54231340 -0.67625750 -0.81862390 -0.75267413 -0.58295510 -0.60627662 -0.86111760 -0.67478820 -0.63083863 -0.80310924 -0.86217920 -0.80715063 -0.85986967 -0.75007166 -0.77393410 -0.78953484 -0.64212372 -0.78612691 -0.83118947 -0.90584753 -0.85841809 -0.85618867 -0.92284473 -0.72451664 -0.93641337 -0.75882808 -0.82298346 -0.87393782 -0.75600054 -0.85867680 -0.92658428 -0.79984667 -0.91378923 -0.70085654 -0.76849231 -0.71655108 -0.74442284 -0.73336704 -0.78773790 -0.76655014 -0.77503600 -0.88720928 -0.82575931 -0.72495737 -0.97211666 -0.83982249 -0.86147893 -0.72128918 -0.80468570 -0.69989725 -0.82021594 -0.74445344 -0.85676895 -0.83451533 -0.94491993 -0.80878193 -0.71060217 -0.83955509 -0.85604438 -0.76189828 -0.97215344 -0.73559715 -0.99844442 -0.84581726 -0.79530649 -0.82859098 -0.85414755 -0.90080139 -0.81565171 -0.72125063 -0.78941238 -0.70901955 -0.96208544 -0.83717684 -0.95602135 -0.82395671 -0.77927618 -0.93996493 -0.74910138 -0.86073575 -0.70894451 -0.88420688 -0.95579260 -0.90595710 -0.94454188 -0.68176955 -0.95937664 -0.92719057 -0.95507523 -0.89104124 -0.94949682 -0.75711064 -0.79157350 -0.86973884 -0.88191364 -0.90931902 -0.82249639 -0.92704641 -0.74483634 -0.77816021 -0.82545904 -0.69054693 -0.65797002 -0.82684879 -0.74701995 -0.76288200 -0.79008408 -0.63614882 -0.58849876 -0.69057399 -0.81930976 -0.83187882 -0.68979804 -0.76014626 -0.77308357 -0.68321488 -0.78879384 -0.63397936 -0.81531463 -0.81621507 -0.73480510 -0.79178996 -0.53900012 -0.54927394 -0.67854978 -0.74041861 -0.65589225 -0.65392875 -0.55385351 -0.64415158 -0.47408596 -0.47949124 -0.46104569 -0.63597822 -0.64593994 -0.46016429 -0.65625399 -0.67301704 -0.54907078 -0.42646175 -0.57014672 -0.61891355 -0.65268784 -0.38899186 -0.48058160 -0.54066251 -0.44683244 -0.40099187 -0.53087452 -0.41533463 -0.55413539 -0.31975230 -0.38584219 -0.54128555 -0.45043085 -0.38521408 -0.28791263 -0.39983744 -0.36237248 -0.33769218 -0.25654746 -0.47917198 -0.39476899 -0.41415379 -0.29108747 -0.22336144 -0.33462810 -0.23129574 -0.36627722 -0.29036483 -0.32976742 -0.16838353 -0.22558197 -0.17084183 -0.37723525 -0.31735366 -0.16165087 -0.31790539 -0.36324612 -0.23320422 -0.07377930 -0.26684486 -0.16514649 -0.21876921 -0.30911586 -0.15754229 -0.05003342 -0.21088319 -0.26522358 -0.19543087 -0.06150904 -0.15123613 -0.04251552 -0.22674447 -0.00548360 -0.09380448 -0.19130359 -0.06974546 0.03316645 0.10451750 0.13318090 0.14287825 0.12663483 0.12735921 0.11785502 0.05399111 0.02310107 -0.05447159 0.11373937 0.18651238 0.01967946 0.19933240 -0.02150164 0.08090224 0.05771156 0.03313547 0.18655865 0.10217115 0.30499147 0.17685759 0.25883271 0.05106788 0.23883345 0.24014347 0.31939558 0.28363850 0.36057403 0.37776511 0.16266010 0.18468959 0.37412088 0.16493866 0.27355955 0.25646976 0.39658594 0.21742907 0.43375465 0.44059680 0.37527296 0.30131333 0.25632545 0.43248802 0.26183493 0.28270127 0.31260374 0.41850861 0.49460106 0.55928018 0.46149694 0.33608385 0.42505124 0.53281084 0.58562340 0.44580350 0.51773380 0.62318199 0.56543053 0.55702118 0.50451788 0.53788462 0.66165961 0.53545804 0.58027218 0.56078769 0.66321717 0.63853916 0.67255114 0.63311715 0.61403685 0.64641156 0.53175917 0.64365685 0.81958927 0.77153849 0.76443431 0.78377632 0.78935216 0.82359956 0.80984901 0.88052584 0.62840231 0.72182497 0.75856720 0.69626341 0.63774903 0.92673503 0.86004646 0.69414193 0.70168969 0.87627167 0.78655913 0.70255391 0.81018402 0.73706183 0.94100404 0.98749565 0.71685941 0.91740656 0.93283270 0.81216546 0.99576493 0.83765605 0.76410935 0.79055060 1.00835490 0.98876426 1.01664203 0.97499515 1.04156258 0.81048491 0.92758082 0.88671855 0.96188540 1.08758474 0.91317277 1.01426151 0.84785457 0.89193031 1.10084342 0.91435254 1.10994973 0.96747847 1.07234706 0.89159098 1.10095520 1.03520034 1.17295058 0.98140813 1.01187088 0.93736583 1.19694057 1.04139422 0.94107394 1.13468057 1.07559455 1.02577300 1.15709952 1.18544653 1.01426872 1.10189654 1.07543968 0.99542793 1.13139281 1.23552032 0.98955388 1.23006623 1.12796079 1.09368150 1.01374540 1.04475481 1.10706446 1.13495438 1.08368270 1.21129209 1.24583434 1.20343184 1.10690977 1.16791113 1.18056776 1.02795621 1.13995470 1.08551974 1.16713387 1.27772745 1.12371043 1.00645130 1.27612750 1.27547684 1.10605928 1.07704913 1.23549556 1.15319768 1.16866651 1.20543187 1.02769810 1.26163819 1.28253125 1.02831359 1.25268557 1.27122510 1.00119453 1.15418298 1.19136803 1.11089471 1.18912884 1.22208196 1.16472007 1.18027919 1.07275474 1.23973563 1.11422758 1.17395758 1.23270628 1.06181889 1.09900245 1.14293972 1.10762639 0.99928802 1.19309596 0.97707800 1.09363120 0.97320573 1.25198878 1.11307790 1.22629576 1.06531665 1.21251841 1.02043378 1.21329481 1.20550529 1.05315589 1.11747697 1.09652739 1.19078638 0.98277493 0.91568345 1.17460920 0.97678927 0.97543957 1.08989249 0.98452216 1.13630918 1.14909881 1.16288495 0.99170460 1.10996751 0.91172401 1.04707171 1.06406382 0.87488959 1.00315855 1.10496603 0.91200344 0.89776356 1.07356660 0.96459081 0.85581649 0.87343379 0.99560588 0.96104073 0.87356215 0.96648373 0.98826459 0.85133566 0.88434497 0.86279534 0.98194643 0.78149541 1.00471647 0.81415939 0.87023617 0.94847409 0.90947244 0.74418355 0.90104216 0.72350732 0.96126589 0.93601642 0.81713809 0.85893691 0.94056437 0.67751179 0.85782993 0.87249271 0.85096391 0.66589564 0.72925841 0.59697813 0.68214259 0.61682494 0.70336931 0.73163946 0.78925089 0.66919665 0.69461407 0.80408837 0.78757291 0.67271791 0.77097367 0.50750304 0.72580512 0.57491676 0.53422389 0.70346651 0.55229769 0.48850505 0.43829661 0.70741716 0.61580104 0.66074890 0.67513450 0.58825147 0.65016882 0.44266012 0.62201242 0.62297854 0.42758877 0.35015729 0.54889709 0.33466873 0.51828696 0.42446934 0.47589274 0.32175635 0.42070112 0.44174103 0.24613885 0.37330653 0.48835478 0.24690513 0.33567729 0.39097737 0.27172363 0.45856268 0.37188110 0.21576389 0.31026197 0.39771377 0.29137109 0.33978516 0.37261493 0.34674729 0.12349096 0.13101163 0.11038146 0.06297777 0.04704483 0.21326266 0.20704628 0.29001042 0.22440620 0.08467800 0.13300687 0.05178561 0.18419775 -0.01062202 0.16817510 0.17731780 0.14797617 0.01558162 0.07977723 0.03521604 -0.08922887 0.12327960 0.07053307 -0.06495401 0.13580687 -0.10977710 -0.08478177 -0.06124578 -0.12347323 -0.14570269 -0.00238438 -0.16959116 -0.07679087 -0.15435095 -0.11405536 0.01501765 -0.20742122 -0.28149397 -0.01939526 -0.09691590 -0.15596420 -0.16331930 -0.29852261 -0.03975932 -0.24052423 -0.16999867 -0.24888232 -0.37387768 -0.22183745 -0.24189779 -0.32976574 -0.39930897 -0.16949547 -0.41658405 -0.34516441 -0.21399226 -0.16621070 -0.29085833 -0.24220455 -0.26608107 -0.29781842 -0.30240479 -0.22878003 -0.35846321 -0.40797728 -0.33484099 -0.41223333 -0.51289243 -0.42929915 -0.40501701 -0.45896155 -0.46615574 -0.36830906 -0.44502550 -0.46255746 -0.59097949 -0.55016173 -0.49892102 -0.44950864 -0.43570742 -0.35833431 -0.38397542 -0.64341230 -0.39239932 -0.63693493 -0.40188084 -0.52108981 -0.63522809 -0.69324137 -0.63127981 -0.48411886 -0.71198666 -0.63540150 -0.70880981 -0.70755398 -0.74288305 -0.55741727 -0.74839215 -0.59558941 -0.73470496 -0.59754828 -0.64941256 -0.71964125 -0.56171901 -0.57119035 -0.54097721 -0.82797768 -0.64152341 -0.83691478 -0.81259255 -0.81779350 -0.74492707 -0.78831993 -0.76141661 -0.79534263 -0.75899218 -0.75359534 -0.69259105 -0.65296727 -0.81276484 -0.64500909 -0.68041409 -0.65898458 -0.85632736 -0.89543296 -0.73594601 -0.71248061 -0.89326421 -0.90171280 -0.75472714 -0.69393144 -0.69665796 -0.91753640 -0.72822553 -0.67959906 -0.81813831 -0.93555797 -0.88724159 -0.74283031 -0.95291091 -0.84027361 -0.80804121 -0.68633566 -0.91209333 -0.94204898 -0.78516845 -0.94849910 -0.68786321 -0.91020065 -0.80449024 -0.74298284 -0.74047082 -0.84417200 -0.76396295 -0.71884745 -0.72418642 -0.93120728 -0.83226028 -0.76176621 -0.93954745 -0.77441397 -0.85631434 -0.82440542 -0.92151983 -0.97443880 -0.91054699 -0.72484933 -0.85873399 -0.91885050 -0.77050097 -0.76734189 -0.99210514 -0.73390084 -0.75774751 -0.89915115 -0.79478991 -0.90561804 -0.71442410 -0.90762576 -0.94025486 -0.76597473 -0.84489132 -0.79040637 -0.69477642 -0.88905195 -0.95814105 -0.74166294 -0.86738897 -0.79929333 -0.91754364 -0.94709322 -0.92159730 -0.71706380 -0.87217352 -0.84453291 -0.76161531 -0.70867489 -0.72095685 -0.83543963 -0.88749437 -0.74716895 -0.93661015 -0.84930386 -0.73897513 -0.74922495 -0.82545990 -0.62246832 -0.87819806 -0.69032932 -0.85993980 -0.77227248 -0.64864528 -0.78590708 -0.86648085 -0.71765798 -0.79785149 -0.83562106 -0.66046039 -0.71961772 -0.80552013 -0.82483042 -0.78949375 -0.80423451 -0.74212636 -0.54862047 -0.66858231 -0.74827044 -0.68566569 -0.61031296 -0.64084021 -0.61646169 -0.53418681 -0.67278834 -0.55610163 -0.72749238 -0.75069993 -0.65978384 -0.51002568 -0.63532146 -0.45013658 -0.55358060 -0.62688992 -0.44307741 -0.44498473 -0.45226836 -0.62334014 -0.60755644 -0.45197907 -0.46823404 -0.52352067 -0.37352834 -0.51346831 -0.35026756 -0.49392321 -0.48235425 -0.39498854 -0.50136263 -0.47391599 -0.56208238 -0.36637129 -0.41627733 -0.38312406 -0.33010649 -0.49514135 -0.29560438 -0.27319342 -0.44859216 -0.30996961 -0.41737643 -0.42883352 -0.45093217 -0.29413553 -0.32386262 -0.22711394 -0.38681922 -0.40531548 -0.31989486 -0.29759788 -0.19572772 -0.38305499 -0.39775799 -0.21578570 -0.38614391 -0.34480483 -0.16805101 -0.21243083 -0.19503991 -0.10591393 -0.10096266 -0.17908393 -0.23719706 -0.27479780 -0.03519749 -0.00053954 0.00071140 -0.08100010 -0.23562630 -0.23072944 -0.18871981 -0.22423766 -0.00652856 -0.17100490 -0.01369616 0.04227884 -0.01498124 -0.06179627 0.08130962 -0.06383121 -0.04959725 0.09998561 0.02552694 -0.03736804 0.11401410 -0.04689450 0.19050173 -0.00918657 -0.04079617 -0.03378692 0.18495510 0.20938430 0.19620403 0.21154877 0.28243199 0.14400094 0.25017195 0.15084156 0.31718586 0.04445352 0.34842749 0.23508789 0.17794691 0.25122537 0.18387018 0.15160754 0.31340311 0.32901621 0.37139496 0.24816289 0.22848703 0.26683932 0.27178546 0.46128139 0.41967921 0.28913153 0.39429610 0.45201189 0.48578752 0.51225171 0.43006087 0.28157581 0.33606811 0.54109072 0.41411857 0.49777202 0.54398084 0.39279642 0.49422159 0.40620021 0.34879528 0.58607546 0.37196020 0.49263129 0.45971488 0.45443209 0.60102571 0.68589912 0.42264074 0.65354835 0.67853109 0.71993413 0.74888647 0.50134752 0.62990705 0.72958880 0.68283512 0.78658415 0.79312166 0.80760714 0.54635887 0.66589348 0.63930900 0.59164230 0.60011675 0.80978405 0.73363078 0.86762273 0.88893336 0.72342604 0.71978056 0.68438599 0.75798298 0.71182164 0.77740245 0.77719949 0.73280454 0.70255600 0.79566806 0.82934859 0.78191097 0.89727495 0.83198189 0.83686838 0.95112151 0.96485505 0.95272360 0.97069554 0.89105456 0.91391040 0.94318750 0.78989070 0.84065212 0.95804543 0.87111717 1.01594279 0.87216598 0.80991469 0.89301707 0.97686337 1.10650056 1.02825839 1.04254601 1.00046822 0.99826037 1.10638210 0.96692091 0.99165294 0.92186253 1.09164109 1.03345047 0.98155610 1.08944833 0.91663717 0.89048670 1.07223829 1.09525538 1.07586964 1.17912815 1.10112885 1.07208870 0.99630912 0.93768348 1.14573506 0.97916262 1.01762650 1.01487448 1.10462018 1.10622302 1.18353315 1.21114286 1.18959033 1.24712817 1.01331627 1.24113562 0.97818540 1.03942104 0.97237450 1.17358980 1.24585225 1.14833227 1.02534720 1.13142261 1.15293774 1.04090665 1.08339285 1.20255529 1.15513411 1.03335250 1.10609047 1.11216639 1.16733303 1.00114644 1.16951595 1.27671707 1.02983669 1.21803662 1.29006552 1.18199145 1.21554265 1.09068587 1.13768412 1.01440321 1.11551749 1.10824401 1.08572158 1.24407751 1.13373954 1.23998843 1.23436831 1.08142182 1.01614561 1.01115087 1.18484779 1.11969667 1.26279115 1.11494964 1.03449354 1.14869965 1.26615245 1.18153823 1.09977728 1.05710741 1.23171616 1.25869386 1.08601401 0.99073783 1.02257097 1.13826659 1.01865712 1.04757913 1.09580086 1.05845613 1.04677845 1.08617382 1.01574381 0.94998233 1.13577998 0.98237842 1.17193606 1.05001803 1.02187573 1.14358429 1.13971518 0.96393424 0.94285817 0.95556220 1.08723958 1.14715989 1.04310419 0.93520597 1.09507740 1.14811790 0.93670132 1.12747461 0.92469652 1.10701867 1.10859754 1.00252304 0.98333685 1.10162715 0.84863581 0.97631761 1.00400564 1.03204019 0.87509133 0.80669593 0.83579292 1.01883096 1.07271196 0.89154623 1.06718419 0.86064493 0.79736997 0.86506689 0.91177573 0.92640549 0.89193304 0.81707246 0.76342350 0.75438985 0.74259885 0.90729303 0.82658049 0.71380284 0.88271749 0.71901479 0.89861798 0.80413725 0.80684979 0.69697534 0.86223874 0.77698645 0.78246216 0.72982184 0.81155065 0.60907988 0.75747287 0.82942552 0.69723355 0.75007112 0.63698908 0.71977378 0.61275338 0.76043937 0.75085733 0.78961740 0.62802717 0.62307548 0.65719209 0.72122209 0.46893743 0.50685412 0.72480213 0.71710700 0.55958896 0.65786432 0.68415776 0.59814809 0.49883185 0.49960143 0.50026267 0.56289615 0.48947247 0.62654560 0.43755667 0.42340134 0.58096874 0.46632542 0.51793441 0.32103729 0.40994105 0.28676452 0.45368452 0.45609500 0.51097736 0.42358292 0.42283941 0.46215003 0.33660788 0.32396575 0.41841955 0.41416695 0.21399943 0.15468668 0.15413064 0.17005454 0.16867449 0.29506558 0.10621926 0.22910718 0.28097441 0.10190459 0.12830666 0.13422549 0.08933728 0.12462755 0.25785132 0.09740923 0.23020691 0.15335076 0.14392860 0.18671909 0.18961941 0.21779741 -0.02099002 0.16580568 -0.02556331 -0.08365673 -0.06408537 -0.07212307 -0.08368152 0.14848432 -0.06003020 0.13091315 0.02967831 0.09013237 -0.07134778 -0.12043391 -0.14490460 -0.04719079 -0.14411503 -0.13864522 -0.23544701 -0.07356046 0.02929030 -0.01416724 -0.27635690 -0.09812090 -0.19010196 -0.27320237 -0.15467509 -0.20146257 -0.18069531 -0.07939029 -0.30977616 -0.23352429 -0.35551152 -0.26817275 -0.17499128 -0.37234753 -0.20986728 -0.33020432 -0.24861384 -0.39164244 -0.31525654 -0.45129201 -0.39527133 -0.39370944 -0.32818561 -0.42581539 -0.39519856 -0.28332712 -0.39217638 -0.50807480 -0.41627800 -0.39937380 -0.30250114 -0.46732764 -0.32015119 -0.40519516 -0.56673796 -0.51314325 -0.42245238 -0.46323939 -0.55547960 -0.55122479 -0.39666205 -0.45325556 -0.60287449 -0.43887351 -0.54079580 -0.53000061 -0.46393323 -0.56308868 -0.68640188 -0.67552196 -0.52772044 -0.57829674 -0.44109610 -0.69752745 -0.62021040 -0.57580368 -0.71279316 -0.48157641 -0.56947570 -0.49430278 -0.58315127 -0.77436232 -0.68992326 -0.75746267 -0.60826316 -0.78488775 -0.60682029 -0.67162432 -0.72894810 -0.67138568 -0.61976821 -0.59330131 -0.74806628 -0.75475803 -0.74991071 -0.65868205 -0.60533592 -0.64012116 -0.61081432 -0.61701825 -0.83128725 -0.63270433 -0.60445339 -0.66573695 -0.63867391 -0.88524382 -0.71562901 -0.81654553 -0.72568690 -0.65779035 -0.81345687 -0.69926686 -0.88250916 -0.78057149 -0.75171230 -0.72914098 -0.85466801 -0.87065782 -0.67804503 -0.77132265 -0.93077168 -0.77321043 -0.90661043 -0.73373225 -0.70997764 -0.87166252 -0.93342484 -0.74662352 -0.88279655 -0.90468599 -0.92229859 -0.96344091 -0.82029513 -0.86635076 -0.76398666 -0.84429460 -0.87634302 -0.97458633 -0.93003216 -0.83200891 -0.87290934 -0.72664595 -0.98078054 -0.86524736 -0.83748927 -0.95904787 -0.83731498 -0.74262182 -0.94056022 -0.95331585 -0.98151841 -0.80144270 -0.99391730 -0.91180045 -0.70651751 -0.76870598 -0.92432659 -0.79203086 -0.95444357 -0.80589109 -0.73666536 -0.72266607 -0.88683160 -0.84408648 -0.78466270 -0.77572095 -0.84703317 -0.87425904 -0.89760515 -0.95686920 -0.84429089 -0.92581657 -0.85365630 -0.69476079 -0.81509398 -0.69171286 -0.93574004 -0.66267741 -0.92883075 -0.86089309 -0.71620582 -0.76798411 -0.80572265 -0.85275217 -0.89884194 -0.84679941 -0.88172876 -0.83290733 -0.89131542 -0.67077733 -0.62497024 -0.84691940 -0.69643896 -0.89232878 -0.71482460 -0.69449415 -0.87964368 -0.88521544 -0.83879954 -0.61805210 -0.78910972 -0.70747350 -0.70528789 -0.68655610 -0.75173309 -0.72233417 -0.71668633 -0.54036179 -0.81268053 -0.70542045 -0.58128569 -0.63464292 -0.71416503 -0.53054778 -0.76712515 -0.69325018 -0.51668603 -0.57928292 -0.56481762 -0.62157134 -0.71488955 -0.46541648 -0.47926218 -0.60610012 -0.48005258 -0.62613149 -0.60644523 -0.47127603 -0.67285512 -0.40996288 -0.68783523 -0.59236988 -0.65909540 -0.53338543 -0.42176278 -0.37710379 -0.48356183 -0.39462901 -0.45930406 -0.39502665 -0.60964587 -0.46144366 -0.52138396 -0.49605139 -0.29022735 -0.50949795 -0.40776635 -0.48795896 -0.37712145 -0.23943504 -0.49087389 -0.23552687 -0.47621076 -0.44889537 -0.30215837 -0.44895120 -0.45424977 -0.27207394 -0.45277155 -0.15654031 -0.28135281 -0.32201515 -0.21311527 -0.13183992 -0.29226612 -0.18992206 -0.20797875 -0.14678949 -0.19254526 -0.24793329 -0.09624811 -0.27434280 -0.09356216 -0.02413836 -0.22933012 -0.09109840 -0.09527898 -0.16065038 -0.12602100 0.01886156 0.02973236 -0.02666632 -0.12143583 -0.21508785 -0.04248271 -0.03817738 -0.09124401 0.07607360 0.00920334 0.01889774 -0.06971891 -0.12615591 -0.05055179 -0.05833149 -0.01506118 0.14565164 -0.05084034 -0.04163464 0.07356843 0.11193346 -0.01065833 0.14154419 0.21408030 0.20557303 0.06025923 0.08529797 0.05584683 0.14512992 0.11889022 0.11482813 0.32040594 0.17077392 0.17467749 0.24868274 0.10135198 0.15233437 0.31780258 0.28320533 0.18066368 0.38355886 0.26754153 0.31374155 0.31858517 0.22558998 0.20441022 0.32895908 0.20870614 0.33982371 0.38645578 0.42047684 0.24883046 0.46123454 0.30873594 0.44560205 0.45962858 0.51851106 0.31325066 0.56232188 0.43069480 0.44476882 0.43194952 0.51034902 0.44173135 0.47227934 0.47645962 0.57007695 0.58956886 0.69705262 0.69187964 0.52278230 0.48464224 0.71163794 0.53135138 0.61893579 0.73836403 0.49842391 0.55751367 0.61706658 0.67096769 0.77615587 0.58036525 0.81355376 0.66213290 0.77582630 0.70633678 0.65648186 0.69485337 0.78896569 0.85662141 0.85687058 0.63831941 0.64186704 0.88185397 0.81760756 0.64156681 0.78863671 0.91323277 0.76822560 0.74766770 0.73774217 0.73522803 0.79638016 0.86800198 0.77728837 0.89064334 0.95234831 0.74916597 0.94367136 0.92632854 0.88092686 1.02510927 0.78079938 0.93815381 0.83497076 0.78100297 0.95158824 1.03653813 0.95711763 1.04810427 0.86363628 0.99445807 0.86613808 0.90656257 0.83093834 1.04144068 1.12214038 1.06665333 1.07432210 1.01519924 0.94237475 0.93631594 0.95376027 1.16172966 0.94683519 1.04357250 0.94853980 1.02182226 0.93875685 1.01316217 1.14285896 1.15284872 1.18426365 1.07927014 1.16645574 1.13746896 0.94166135 0.97614434 1.00592987 1.01341452 0.99387011 1.01658915 1.03190262 1.23784357 1.05936492 1.04746671 1.08240867 1.05446661 1.19360691 1.07685830 1.00882967 1.15884209 1.08257332 1.08693151 1.00063130 1.24217014 1.12122899 1.00888491 1.25871827 1.07329356 1.17439216 1.19013118 1.05282700 1.28196204 1.19454512 1.15835093 1.25749970 1.16467166 1.00462548 1.14355901 1.24159945 1.22035559 1.17149316 1.00264637 1.21548413 1.13477706 1.19768320 1.22550978 1.24061813 1.00749234 1.23214021 1.16774972 1.01962935 1.07143102 1.03503135 1.16328819 1.15509202 1.01222642 1.28673244 1.06408598 1.08185455 1.07576631 0.99643896 1.14035728 1.05685503 1.10062477 1.26013120 1.24942975 1.00768925 1.14647315 1.07426202 1.17953848 1.11809538 1.03647062 1.10323314 1.20905632 1.16652841 1.00574567 0.98990980 1.05048388 1.19454607 1.13772292 1.11888993 0.96727113 0.94481590 1.17992782 1.03918010 1.05522655 1.04281019 1.05511033 0.97761004 0.96100065 1.15681274 1.15489884 1.05863139 0.98227062 1.04735070 1.06330679 1.12603069 0.87867718 1.00890943 0.97038640 1.02155837 0.99855235 0.89303897 0.85095127 0.81681839 0.82571939 0.89883663 1.02987117 0.89057950 0.96963522 1.07538069 0.96558927 0.92671577 0.82797844 0.97369484 1.01181086 0.99634892 0.91074451 0.92119839 0.99235094 0.84080388 0.79070831 0.88620552 0.77805847 0.86876270 0.68906825 0.96577741 0.72194340 0.83457706 0.74904545 0.85240148 0.63773865 0.64159056 0.89179249 0.63207862 0.69747994 0.74756813 0.65560103 0.73631459 0.79948413 0.71351099 0.82819807 0.58435863 0.65681266 0.60737556 0.69417021 0.51708352 0.51659734 0.58565672 0.50955723 0.52226076 0.57375309 0.46544277 0.65735155 0.62800220 0.47879501 0.43615665 0.53040145 0.53817422 0.45086942 0.64170488 0.55095673 0.36917622 0.62276141 0.47944334 0.35155903 0.35659024 0.61476280 0.56562770 0.48075490 0.29471058 0.37378943 0.40654321 0.28746648 0.41938294 0.33614940 0.36381111 0.39227022 0.23160216 0.21656254 0.27983760 0.33623902 0.33844072 0.23248010 0.42395073 0.38796096 0.26369643 0.41503038 0.28395878 0.17086142 0.33375730 0.21599917 0.14563635 0.34729848 0.09347788 0.19446227 0.32227721 0.21519920 0.19510559 0.14159961 0.16403884 0.25409966 0.08357477 0.02934404 0.07778192 0.02281810 0.06412969 0.10904208 0.07121549 0.01650023 0.15295699 -0.02890813 -0.00892664 0.01647158 -0.13019410 -0.08921250 -0.13294217 -0.14870240 0.07891561 -0.18796210 0.04393967 -0.06536204 -0.19317659 -0.08988457 -0.06688879 -0.22933483 0.02741481 -0.07977289 -0.14693744 -0.03571967 -0.22553892 -0.06670887 -0.22468387 -0.05043268 -0.26900352 -0.06448176 -0.20771103 -0.20089218 -0.08142189 -0.15747418 -0.30382254 -0.38975530 -0.40300820 -0.18141877 -0.31070908 -0.32806778 -0.29532011 -0.19350949 -0.34822798 -0.29749050 -0.45912121 -0.39547426 -0.46147282 -0.44006745 -0.40839500 -0.44949329 -0.47435901 -0.35731518 -0.31586082 -0.50150668 -0.30341302 -0.35674880 -0.42765962 -0.30564066 -0.43516047 -0.54725318 -0.36310465 -0.36964528 -0.54200303 -0.54558344 -0.39929532 -0.51109503 -0.65077375 -0.44036199 -0.55312140 -0.60442207 -0.59557690 -0.59269642 -0.47141952 -0.70525785 -0.50580044 -0.46885969 -0.65171131 -0.54711793 -0.68124928 -0.57079655 -0.74133734 -0.48026305 -0.59363715 -0.66777424 -0.77990023 -0.53790495 -0.62013561 -0.55279027 -0.66162064 -0.81641407 -0.54876530 -0.70689331 -0.61592950 -0.79575855 -0.60188696 -0.57885834 -0.62355335 -0.63491044 -0.74551322 -0.66144053 -0.70722376 -0.70620463 -0.78282650 -0.67961761 -0.84712610 -0.89933910 -0.73551113 -0.74439384 -0.74722761 -0.70816052 -0.64222728 -0.64107433 -0.65712790 -0.75055169 -0.65750414 -0.90377315 -0.84001265 -0.93453581 -0.78725129 -0.73070602 -0.90052514 -0.82993963 -0.93118921 -0.87240302 -0.73196627 -0.80745190 -0.74025870 -0.78164005 -0.70762435 -0.95950984 -0.92703584 -0.85682013 -0.76163634 -0.71744331 -0.97923107 -0.94727678 -0.86277922 -0.76199618 -0.83529669 -0.76744581 -0.94391368 -0.79399862 -0.81108482 -0.99539108 -0.77604176 -0.70115348 -0.96068456 -0.89132906 -0.94244689 -0.78561457 -0.94663877 -0.70390926 -0.99472916 -0.98765499 -0.75795984 -0.74088646 -0.82841365 -0.77142104 -0.84106609 -0.82031516 -0.93793297 -0.84308730 -0.97771279 -0.97492661 -0.88986509 -0.79972282 -0.71987194 -0.78381858 -0.77853116 -0.77356313 -0.74041421 -0.78016112 -0.82024290 -0.87448653 -0.69144182 -0.89533956 -0.81341281 -0.74207476 -0.88521856 -0.70499653 -0.79433261 -0.67974950 -0.84449453 -0.66593014 -0.66493827 -0.76357618 -0.90589583 -0.82280623 -0.84646662 -0.84564936 -0.85368281 -0.91732180 -0.64579768 -0.77354112 -0.73186360 -0.80641723 -0.59851271 -0.59707912 -0.59832261 -0.68315862 -0.66045365 -0.77326343 -0.71173210 -0.78155851 -0.64296563 -0.61990276 -0.82373211 -0.77623588 -0.77609635 -0.64454495 -0.60862058 -0.57019761 -0.80908096 -0.74827551 -0.66226325 -0.68347263 -0.68879340 -0.76559742 -0.55011477 -0.65140185 -0.56352127 -0.59401661 -0.73735735 -0.65392564 -0.44984628 -0.45326852 -0.61246113 -0.53365358 -0.54320822 -0.45574242 -0.41047293 -0.66793299 -0.41691044 -0.50724832 -0.61027311 -0.59467410 -0.44184521 -0.46694451 -0.46241835 -0.34002932 -0.44826188 -0.58498988 -0.55703268 -0.56840826 -0.54712523 -0.38143380 -0.38279285 -0.45480627 -0.50940646 -0.43308833 -0.30157163 -0.41319296 -0.29810850 -0.42754180 -0.31551223 -0.23333719 -0.42728779 -0.33733326 -0.43875523 -0.42410462 -0.43573248 -0.42221608 -0.24894660 -0.30461650 -0.22738083 -0.15288979 -0.17164253 -0.09868504 -0.14785089 -0.09237781 -0.14201052 -0.27833727 -0.12927970 -0.12759807 -0.09421969 -0.09258114 -0.21173038 -0.14458469 -0.05623276 -0.10671795 0.01721044 -0.20782812 0.02254149 -0.01426748 -0.14436101 -0.03224773 -0.07185765 -0.16208839 -0.02629881 0.10956366 -0.03880379 0.01570359 -0.11841802 -0.08186173 -0.08302233 -0.11092929 -0.03024388 -0.03307875 0.01539724 -0.04190147 0.22734419 0.09179939 0.06408058 0.03267129 0.07713419 0.09742196 0.26559339 0.14634473 0.19045887 0.01914446 0.20401794 0.27093264 0.24483972 0.21616524 0.31538309 0.36635481 0.18171140 0.33667300 0.19304749 0.12189973 0.15560096 0.23588498 0.23883628 0.16245662 0.21558009 0.30996591 0.41663360 0.40079423 0.42057369 0.35392153 0.50152079 0.53215372 0.52495791 0.39331694 0.53599346 0.39008273 0.46465521 0.46142058 0.55662211 0.39782668 0.52086452 0.51199802 0.53767791 0.44310364 0.45896593 0.42524541 0.40826778 0.47327069 0.50294938 0.56639039 0.71203157 0.43231342 0.64575553 0.71343568 0.71058584 0.49549120 0.75518036 0.60967857 0.74889920 0.75437081 0.61009518 0.70150829 0.78009225 0.53553605 0.56074273 0.65911534 0.59920886 0.57297413 0.80565801 0.67733755 0.83252994 0.64743705 0.80619141 0.87398065 0.84633044 0.69589288 0.74244692 0.75140826 0.73032291 0.75884675 0.69124429 0.80805766 0.81635537 0.69596522 0.88561482 0.71948213 0.75949340 0.92115768 0.88907158 0.73138749 0.82280468 0.85609136 0.79371025 0.77870190 0.90106852 0.88039153 1.02299110 0.94315761 1.03334662 0.93232211 0.80445466 0.80769610 0.86194518 0.92765360 1.03904810 0.87704271 0.91839479 1.03370914 0.93176909 0.94748279 0.90273915 0.97753803 1.13499788 1.13756023 0.99417927 1.08351009 0.96122644 1.17515934 1.08207952 0.96118162 0.93632625 1.07742671 0.99412319 0.93723293 0.96738672 0.93858462 1.13177788 1.16573098 1.17701215 1.01782355 1.21048834 1.12743123 0.95257802 1.05459395 1.11451716 1.14568348 1.09421713 1.20627285 1.00903848 1.26059126 1.22072602 1.07498684 1.16008941 1.06850822 1.00621294 1.13787305 1.23087262 1.21423468 1.27102151 1.08836825 1.10670110 1.03627999 1.09254489 1.15971539 1.15977876 1.04379624 1.03167656 1.11689499 1.24742517 1.05409123 1.14930735 1.03734680 1.25912189 1.22990799 1.16930128 1.11684696 1.14689839 1.26570927 1.27083352 1.14841678 1.15714935 1.27067281 1.17062368 1.22896154 1.19372663 1.13518811 1.05910450 1.17273509 1.04592063 1.04848154 1.24631305 1.02379819 1.17806689 1.11377923 1.16445799 1.19991582 1.06755170 0.98725729 1.22272091 1.08046558 1.16558242 1.23330739 1.04413546 1.25849342 1.20655212 1.19067581 1.14718779 1.11014214 1.05978619 1.18709859 1.11558245 1.16793393 1.22610999 1.16255688 1.17813751 1.06403337 1.17647279 1.01040510 0.96766000 1.05009547 0.90678424 1.14123734 0.96769641 1.08703430 1.11722075 1.07880365 1.06457988 0.93556931 1.00251609 1.13506314 0.92122532 0.90630045 0.91989555 1.06540302 0.92650180 1.00233866 0.87087644 0.83608380 0.89661394 0.86721564 1.06464123 1.06680422 0.78907780 0.95130555 0.77997665 0.88784553 0.91031630 0.99933561 0.92805982 0.81035540 0.99837107 0.95025089 0.88188536 0.97518547 0.80934632 0.79305500 0.87013633 0.70322393 0.78241242 0.71851837 0.89793672 0.86416235 0.84193457 0.90600729 0.87031846 0.78080251 0.61294091 0.62871682 0.74671085 0.86994138 0.82896975 0.84835226 0.85161293 0.66303138 0.63917299 0.76945220 0.58966593 0.80521407 0.78795552 0.60997086 0.59504207 0.69064002 0.68903558 0.70532896 0.63445202 0.47658271 0.60631755 0.44238253 0.64769285 0.60920335 0.58201152 0.46109656 0.59789755 0.59188070 0.46850465 0.36573726 0.59963393 0.56824173 0.48061448 0.53034549 0.54611288 0.39843474 0.56377998 0.45310335 0.35685107 0.34089712 0.51822441 0.35130949 0.27676778 0.50592228 0.40751326 0.49714446 0.25082737 0.43147795 0.32115542 0.34039067 0.16675029 0.31273124 0.32355342 0.27300305 0.13153084 0.25825198 0.10971040 0.33688102 0.25222442 0.27115200 0.24803176 0.23090766 0.32004081 0.07697073 0.15636092 0.25661088 0.14297888 0.21261192 0.02785595 0.17138427 0.22823360 -0.00728353 0.06236679 -0.06348118 -0.01827994 0.10388281 0.15549228 -0.01243098 -0.11760072 0.13589448 -0.00427221 0.11766232 -0.06695341 0.03212979 -0.17980328 -0.04115152 -0.10510988 -0.11359820 0.06181524 -0.00877090 -0.14345595 -0.06346972 -0.13831684 -0.09966531 0.00562747 -0.10704744 -0.25617858 -0.05939064 -0.10251104 -0.29716359 -0.29083578 -0.25952804 -0.23091140 -0.20878102 -0.29405862 -0.13744583 -0.15720348 -0.32208124 -0.22862364 -0.39195173 -0.23047072 -0.33624031 -0.24856616 -0.36973478 -0.26306184 -0.35787638 -0.36723326 -0.43141175 -0.28481728 -0.26500418 -0.24142564 -0.37365053 -0.47841016 -0.36389585 -0.49367057 -0.43831004 -0.31375242 -0.44914041 -0.30829967 -0.48214762 -0.39261131 -0.43345168 -0.58767254 -0.50204517 -0.35611991 -0.62457259 -0.53366470 -0.58426328 -0.59562343 -0.56427420 -0.40155672 -0.53534727 -0.45236616 -0.59542718 -0.57000533 -0.42931162 -0.68170468 -0.70739443 -0.52347623 -0.46253036 -0.71603725 -0.55978993 -0.71799627 -0.56006578 -0.58693350 -0.76778603 -0.54773327 -0.49737588 -0.66826498 -0.70183318 -0.79650489 -0.74939362 -0.64837670 -0.64791178 -0.75812984 -0.64306046 -0.82672793 -0.56791396 -0.82753079 -0.76023523 -0.67016632 -0.71927404 -0.71604874 -0.76638065 -0.65414901 -0.80468284 -0.69918045 -0.62174377 -0.80354416 -0.66297053 -0.67487742 -0.87794608 -0.87200976 -0.79861782 -0.72071642 -0.73331137 -0.73024250 -0.93493954 -0.90259868 -0.71534154 -0.69517625 -0.72680900 -0.67058412 -0.68097908 -0.89282757 -0.80958022 -0.72885260 -0.81100685 -0.78499582 -0.80511517 -0.75556648 -0.95802267 -0.83128887 -0.91213123 -0.88177661 -0.81928971 -0.76336416 -0.86436827 -0.83726571 -0.95225181 -0.92778605 -0.90558186 -0.85953566 -0.92343598 -0.91743723 -0.72973752 -0.82206663 -0.71690270 -0.81357778 -0.92418278 -0.96893408 -0.83598299 -0.86719534 -0.79253404 -0.77205091 -0.87985327 -0.82915251 -0.93729832 -0.71541199 -0.84402581 -0.91429127 -0.92762111 -0.70958255 -0.78763337 -0.78099689 -0.79508191 -0.75716880 -0.81531964 -0.83699399 -0.72274736 -0.86678706 -0.91008781 -0.89649882 -0.70756574 -0.76610682 -0.71880731 -0.85883610 -0.78015466 -0.95811702 -0.68900019 -0.82141585 -0.80360240 -0.72681721 -0.85288767 -0.76290355 -0.84947986 -0.85097502 -0.74714574 -0.80742985 -0.90314572 -0.85954732 -0.63514567 -0.71320651 -0.72114360 -0.81716052 -0.90496270 -0.73559595 -0.89157504 -0.81870023 -0.83648325 -0.75435925 -0.65393202 -0.69143871 -0.78061249 -0.78252515 -0.84169519 -0.80852541 -0.63858043 -0.82290043 -0.56907685 -0.71011848 -0.80962186 -0.65632930 -0.57279185 -0.71238198 -0.57681273 -0.59238371 -0.62162832 -0.67975858 -0.66857556 -0.65201812 -0.64731275 -0.70217538 -0.61237872 -0.74292651 -0.57884630 -0.72687735 -0.47319070 -0.47004899 -0.61968757 -0.42199224 -0.42073388 -0.40347437 -0.64556965 -0.68476444 -0.60387239 -0.56705794 -0.59349487 -0.42921429 -0.58062289 -0.50622294 -0.55521319 -0.52153555 -0.34655223 -0.60573152 -0.56191706 -0.47714706 -0.33330216 -0.51337262 -0.28858851 -0.26996812 -0.44002398 -0.24878075 -0.49919752 -0.29906604 -0.34502209 -0.32390906 -0.35465916 -0.42681956 -0.44098935 -0.28490343 -0.22591042 -0.25687446 -0.30737309 -0.15655220 -0.25344904 -0.35382355 -0.20760716 -0.30743853 -0.16978658 -0.08581049 -0.29508623 -0.08716053 -0.14848381 -0.31946491 -0.26488902 -0.04882750 -0.17583068 -0.04551683 -0.06696414 -0.28571627 -0.05039189 -0.06627171 -0.00207473 ================================================ FILE: testData/testSinusoid_output.txt ================================================ 0.13687262547490, DN_OutlierInclude_n_001_mdrmd, 8.703000 -0.13777244551090, DN_OutlierInclude_p_001_mdrmd, 6.593000 1.27292807660985, DN_HistogramMode_5, 0.041000 -1.12758575737747, DN_HistogramMode_10, 0.039000 1.64629633438112, CO_Embed2_Dist_tau_d_expfit_meandiff, 8.099000 119.74079600337870, CO_f1ecac, 6.009000 2.00000000000000, CO_FirstMin_ac, 4.579000 1.07949995567938, CO_HistogramAMI_even_2_5, 0.320000 -0.00017509308632, CO_trev_1_num, 0.110000 0.00625000000000, FC_LocalSimple_mean1_tauresrat, 13.819000 0.14051134209844, FC_LocalSimple_mean3_stderr, 0.190000 1.00000000000000, IN_AutoMutualInfoStats_40_gaussian_fmmi, 1.845000 0.82200000000000, MD_hrv_classic_pnn40, 0.041000 6.00000000000000, SB_BinaryStats_diff_longstretch0, 0.051000 301.00000000000000, SB_BinaryStats_mean_longstretch1, 0.046000 1.38225822030023, SB_MotifThree_quantile_hh, 1.417000 0.77551020408163, SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1, 3.221000 0.69387755102041, SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1, 1.645000 0.98817221358274, SP_Summaries_welch_rect_area_5_1, 2.410000 0.00997087512126, SP_Summaries_welch_rect_centroid, 2.218000 0.01005896635449, SB_TransitionMatrix_3ac_sumdiagcov, 6.992000 628.00000000000000, PD_PeriodicityWang_th0_01, 17.879000 ================================================ FILE: testData/test_output.txt ================================================ -0.23703703703704, DN_OutlierInclude_n_001_mdrmd, 0.252000 0.40740740740741, DN_OutlierInclude_p_001_mdrmd, 0.302000 -0.61479911484527, DN_HistogramMode_5, 0.003000 -0.78225446555221, DN_HistogramMode_10, 0.003000 7.13507860878856, CO_Embed2_Dist_tau_d_expfit_meandiff, 0.234000 32.50260547693646, CO_f1ecac, 0.192000 77.00000000000000, CO_FirstMin_ac, 0.191000 1.00638907799376, CO_HistogramAMI_even_2_5, 0.014000 0.00001782472612, CO_trev_1_num, 0.006000 0.84782608695652, FC_LocalSimple_mean1_tauresrat, 0.388000 0.08029384289851, FC_LocalSimple_mean3_stderr, 0.007000 40.00000000000000, IN_AutoMutualInfoStats_40_gaussian_fmmi, 0.086000 0.31970260223048, MD_hrv_classic_pnn40, 0.002000 83.00000000000000, SB_BinaryStats_diff_longstretch0, 0.002000 88.00000000000000, SB_BinaryStats_mean_longstretch1, 0.003000 1.21058781724385, SB_MotifThree_quantile_hh, 0.034000 0.29545454545455, SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1, 0.169000 0.75000000000000, SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1, 0.073000 0.99313877887425, SP_Summaries_welch_rect_area_5_1, 0.075000 0.03681553890926, SP_Summaries_welch_rect_centroid, 0.069000 0.08000000000000, SB_TransitionMatrix_3ac_sumdiagcov, 0.198000 0.00000000000000, PD_PeriodicityWang_th0_01, 0.100000 ================================================ FILE: wrap_Matlab/GetAllFeatureNames.m ================================================ function [featureNamesLong,featureNamesShort] = GetAllFeatureNames(doCatch24) % Retrieve all feature names from featureList.txt if nargin < 1 || isempty(doCatch24) doCatch24 = true; end %------------------------------------------------------------------------------- % Retrieve all (long) feature names from featureList.txt fid = fopen('../featureList.txt','r'); formatSpec = '%s%s'; dataIn = textscan(fid,formatSpec,'CommentStyle','#','EndOfLine','\r\n','CollectOutput',true); fclose(fid); dataIn = dataIn{1}; % Collect one big matrix of cells featureNamesLong = dataIn(:,1); featureNamesShort = dataIn(:,2); %------------------------------------------------------------------------------- % Filter out the two extra features: 'DN_Mean' and 'DN_Spread_Std' isMeanStd = strcmp(featureNamesLong,'DN_Mean') | strcmp(featureNamesLong,'DN_Spread_Std'); assert(sum(isMeanStd) == 2) if ~doCatch24 keepMe = ~isMeanStd; featureNamesLong = featureNamesLong(keepMe); featureNamesShort = featureNamesShort(keepMe); fprintf(1,'Using catch22.\n'); else fprintf(1,'Using catch24.\n'); end end ================================================ FILE: wrap_Matlab/M_wrapper.c ================================================ #include "mex.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void M_wrapper_double( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[], double (*f) (const double*, const int), int normalize ) { double *inMatrix; /* 1xN input matrix */ int ncols; double *outMatrix; /* output matrix */ // check inputs if(nrhs != 1) { mexErrMsgIdAndTxt("catch22:nrhs", "One input required."); } if(nlhs > 1) { mexErrMsgIdAndTxt("catch22:nlhs", "One output required."); } if( !mxIsDouble(prhs[0]) || mxIsComplex(prhs[0])) { mexErrMsgIdAndTxt("catch22:notDouble", "Input vector must be type double."); } if(mxGetM(prhs[0]) != 1) { mexErrMsgIdAndTxt("catch22:notRowVector", "Input must be a row vector."); } // get input inMatrix = mxGetPr(prhs[0]); ncols = mxGetN(prhs[0]); // set output plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); outMatrix = mxGetPr(plhs[0]); // calculate result if (normalize){ double * y_zscored = malloc(ncols * sizeof * y_zscored); zscore_norm2(inMatrix, ncols, y_zscored); outMatrix[0] = f(y_zscored, ncols); free(y_zscored); } else { outMatrix[0] = f(inMatrix, ncols); } return; } void M_wrapper_int( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[], int (*f) (const double*, const int), int normalize ) { double *inMatrix; /* 1xN input matrix */ int ncols; int *outMatrix; /* output matrix */ // check inputs if(nrhs != 1) { mexErrMsgIdAndTxt("catch22:nrhs", "One input required."); } if(nlhs > 1) { mexErrMsgIdAndTxt("catch22:nlhs", "One output required."); } if( !mxIsDouble(prhs[0]) || mxIsComplex(prhs[0])) { mexErrMsgIdAndTxt("catch22:notDouble", "Input vector must be type double."); } if(mxGetM(prhs[0]) != 1) { mexErrMsgIdAndTxt("catch22:notRowVector", "Input must be a row vector."); } // get input inMatrix = mxGetPr(prhs[0]); ncols = mxGetN(prhs[0]); // set output plhs[0] = mxCreateNumericMatrix(1,1, mxINT32_CLASS, mxREAL); outMatrix = (int*)mxGetData(plhs[0]); // calculate result if (normalize){ double * y_zscored = malloc(ncols * sizeof * y_zscored); zscore_norm2(inMatrix, ncols, y_zscored); outMatrix[0] = f(y_zscored, ncols); free(y_zscored); } else { outMatrix[0] = f(inMatrix, ncols); } return; } ================================================ FILE: wrap_Matlab/M_wrapper.h ================================================ #include "mex.h" extern void M_wrapper_double( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[], double (*f) (const double*, const int), int normalize ); extern void M_wrapper_int( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[], int (*f) (const double*, const int), int normalize ); ================================================ FILE: wrap_Matlab/catch22_CO_Embed2_Dist_tau_d_expfit_meandiff.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &CO_Embed2_Dist_tau_d_expfit_meandiff, 1); return; } ================================================ FILE: wrap_Matlab/catch22_CO_FirstMin_ac.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_int( nlhs, plhs, nrhs, prhs, &CO_FirstMin_ac, 1); return; } ================================================ FILE: wrap_Matlab/catch22_CO_HistogramAMI_even_2_5.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &CO_HistogramAMI_even_2_5, 1); return; } ================================================ FILE: wrap_Matlab/catch22_CO_f1ecac.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &CO_f1ecac, 1); return; } ================================================ FILE: wrap_Matlab/catch22_CO_trev_1_num.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &CO_trev_1_num, 1); return; } ================================================ FILE: wrap_Matlab/catch22_DN_HistogramMode_10.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &DN_HistogramMode_10, 1); return; } ================================================ FILE: wrap_Matlab/catch22_DN_HistogramMode_5.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &DN_HistogramMode_5, 1); return; } ================================================ FILE: wrap_Matlab/catch22_DN_Mean.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &DN_Mean, 0); return; } ================================================ FILE: wrap_Matlab/catch22_DN_OutlierInclude_n_001_mdrmd.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &DN_OutlierInclude_n_001_mdrmd, 1); return; } ================================================ FILE: wrap_Matlab/catch22_DN_OutlierInclude_p_001_mdrmd.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &DN_OutlierInclude_p_001_mdrmd, 1); return; } ================================================ FILE: wrap_Matlab/catch22_DN_Spread_Std.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &DN_Spread_Std, 0); return; } ================================================ FILE: wrap_Matlab/catch22_FC_LocalSimple_mean1_tauresrat.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &FC_LocalSimple_mean1_tauresrat, 1); return; } ================================================ FILE: wrap_Matlab/catch22_FC_LocalSimple_mean3_stderr.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &FC_LocalSimple_mean3_stderr, 1); return; } ================================================ FILE: wrap_Matlab/catch22_IN_AutoMutualInfoStats_40_gaussian_fmmi.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &IN_AutoMutualInfoStats_40_gaussian_fmmi, 1); return; } ================================================ FILE: wrap_Matlab/catch22_MD_hrv_classic_pnn40.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &MD_hrv_classic_pnn40, 1); return; } ================================================ FILE: wrap_Matlab/catch22_PD_PeriodicityWang_th0_01.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_int( nlhs, plhs, nrhs, prhs, &PD_PeriodicityWang_th0_01, 1); return; } ================================================ FILE: wrap_Matlab/catch22_SB_BinaryStats_diff_longstretch0.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &SB_BinaryStats_diff_longstretch0, 1); return; } ================================================ FILE: wrap_Matlab/catch22_SB_BinaryStats_mean_longstretch1.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &SB_BinaryStats_mean_longstretch1, 1); return; } ================================================ FILE: wrap_Matlab/catch22_SB_MotifThree_quantile_hh.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &SB_MotifThree_quantile_hh, 1); return; } ================================================ FILE: wrap_Matlab/catch22_SB_TransitionMatrix_3ac_sumdiagcov.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &SB_TransitionMatrix_3ac_sumdiagcov, 1); return; } ================================================ FILE: wrap_Matlab/catch22_SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &SC_FluctAnal_2_dfa_50_1_2_logi_prop_r1, 1); return; } ================================================ FILE: wrap_Matlab/catch22_SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &SC_FluctAnal_2_rsrangefit_50_1_logi_prop_r1, 1); return; } ================================================ FILE: wrap_Matlab/catch22_SP_Summaries_welch_rect_area_5_1.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &SP_Summaries_welch_rect_area_5_1, 1); return; } ================================================ FILE: wrap_Matlab/catch22_SP_Summaries_welch_rect_centroid.c ================================================ /*================================================================= * * *=================================================================*/ #include #include "mex.h" #include "M_wrapper.h" #include "CO_AutoCorr.h" #include "DN_HistogramMode_10.h" #include "DN_HistogramMode_5.h" #include "DN_Mean.h" #include "DN_Spread_Std.h" #include "DN_OutlierInclude.h" #include "FC_LocalSimple.h" #include "IN_AutoMutualInfoStats.h" #include "MD_hrv.h" #include "PD_PeriodicityWang.h" #include "SB_BinaryStats.h" #include "SB_CoarseGrain.h" #include "SB_MotifThree.h" #include "SB_TransitionMatrix.h" #include "SC_FluctAnal.h" #include "SP_Summaries.h" #include "butterworth.h" #include "fft.h" #include "helper_functions.h" #include "histcounts.h" #include "splinefit.h" #include "stats.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { // check inputs and call feature C-function M_wrapper_double( nlhs, plhs, nrhs, prhs, &SP_Summaries_welch_rect_centroid, 1); return; } ================================================ FILE: wrap_Matlab/catch22_all.m ================================================ function [featureValues, featureNamesLong, featureNamesShort] = catch22_all(data, doCatch24) % catch22_all Calculate all catch22 (or catch24) features from an input time series % % ---INPUTS % data: a univariate time series (row vector) % catch24: set to true to also include mean and standard deviation (a total of 24 % features) % ---OUTPUTS: % featureValues: computed feature values for the input data %------------------------------------------------------------------------------- %% Check inputs and set defaults %------------------------------------------------------------------------------- if nargin < 2 doCatch24 = true; end %------------------------------------------------------------------------------- % Define the features: %------------------------------------------------------------------------------- [featureNamesLong,featureNamesShort] = GetAllFeatureNames(doCatch24); %------------------------------------------------------------------------------- % Compute all features from their local compiled implementations %------------------------------------------------------------------------------- numFeatures = length(featureNamesLong); featureValues = zeros(numFeatures,1); for featureInd = 1:numFeatures featureName = featureNamesLong{featureInd}; fh = str2func(['catch22_', featureName]); featureValues(featureInd) = fh(data'); end end ================================================ FILE: wrap_Matlab/mexAll.m ================================================ % mexAll Mex compile all .c files to be runnable from Matlab. % Path where the C implementation lives basePath = '../C'; ipath = {['-I', basePath], '-I.'}; % List all C files to include in the mex-call CFiles = dir(basePath); CFiles = CFiles(cellfun(@(x) contains(x, '.c'), {CFiles.name})); CFileNames = {CFiles.name}; % Add path to the c file names includeFiles = cellfun(@(x) fullfile(basePath, x), CFileNames, 'UniformOutput', false); % Get function names featureNames = GetAllFeatureNames(true); % mex all feature functions separately numFeatures = length(featureNames); for i = 1:numFeatures featureName = featureNames{i}; fprintf('[%u/%u]: Compiling %s...\n', i,numFeatures,featureName); mex(ipath{:}, ['catch22_', featureName,'.c'], 'M_wrapper.c', includeFiles{:}) fprintf('\n'); end fprintf(1,'All done!\n'); ================================================ FILE: wrap_Matlab/testing.m ================================================ %------------------------------------------------------------------------------- % Get the function names [featureNamesLong,featureNamesShort] = GetAllFeatureNames(); numFeatures = length(featureNamesLong); %------------------------------------------------------------------------------- % Get the data dataFileNames = {'../testData/test.txt', '../testData/test2.txt'}; numTestFiles = length(dataFileNames); fprintf(1,'Testing %u compiled features on %u data files.\n',numFeatures,numTestFiles); %------------------------------------------------------------------------------- % Test all functions on all the data files for j = 1:numTestFiles dataFileName = dataFileNames{j}; fprintf('\n%s\n\n', dataFileName) fileID = fopen(dataFileName,'r'); data = fscanf(fileID,'%f'); for featureInd = 1:numFeatures featureName = featureNamesLong{featureInd}; fh = str2func(['catch22_', featureName]); out = fh(data'); fprintf("%s (%s): %1.6f\n", featureNamesShort{featureInd}, featureName, out); end fclose(fileID); end