TimeSeriesUtil { public static List<Integer> sortIndexes(final double[] vector, final boolean ascending) { Integer[] indexes = new Integer[vector.length]; for (int i = 0; i < indexes.length; i++) { indexes[i] = i; } Arrays.sort(indexes, (i1, i2) -> (ascending ? 1 : -1) * Double.compare(Math.abs(vector[i1]), Math.abs(vector[i2]))); return Arrays.asList(indexes); } private  TimeSeriesUtil(); static boolean isTimeSeries(final INDArray... array); static boolean isTimeSeries(final int length, final INDArray... array); static boolean isTimeSeries(final int length, final double[]... array); static void isTimeSeriesOrException(final INDArray... array); static void isTimeSeriesOrException(final int length, final INDArray... array); static void isTimeSeriesOrException(final int length, final double[]... array); static boolean isSameLength(final INDArray timeSeries1, final INDArray... timeSeries); static boolean isSameLength(final double[] timeSeries1, final double[]... timeSeries); static void isSameLengthOrException(final INDArray timeSeries1, final INDArray... timeSeries); static void isSameLengthOrException(final double[] timeSeries1, final double[]... timeSeries); static INDArray createEquidistantTimestamps(final INDArray timeSeries); static double[] createEquidistantTimestamps(final double[] timeSeries); static double[] getInterval(final double[] timeSeries, final int start, final int end); static INDArray normalizeINDArray(final INDArray array, final boolean inplace); static int getMode(final int[] array); static T getMaximumKeyByValue(final Map<T, Integer> map); static double[] zNormalize(final double[] dataVector, final boolean besselsCorrection); static List<Integer> sortIndexes(final double[] vector, final boolean ascending); static int getNumberOfClasses(final TimeSeriesDataset2 dataset); static List<Integer> getClassesInDataset(final TimeSeriesDataset2 dataset); static void shuffleTimeSeriesDataset(final TimeSeriesDataset2 dataset, final int seed); static Pair<TimeSeriesDataset2, TimeSeriesDataset2> getTrainingAndTestDataForFold(final int fold, final int numFolds, final double[][] srcValueMatrix, final int[] srcTargetMatrix); static TimeSeriesDataset2 createDatasetForMatrix(final int[] targets, final double[][]... valueMatrices); static TimeSeriesDataset2 createDatasetForMatrix(final double[][]... valueMatrices); static String toString(final double[] timeSeries); static double[] keoghDerivate(final double[] t); static double[] keoghDerivateWithBoundaries(final double[] t); static double[] backwardDifferenceDerivate(final double[] t); static double[] backwardDifferenceDerivateWithBoundaries(final double[] t); static double[] forwardDifferenceDerivate(final double[] t); static double[] forwardDifferenceDerivateWithBoundaries(final double[] t); static double[] gulloDerivate(final double[] t); static double[] gulloDerivateWithBoundaries(final double[] t); static double sum(final double[] t); static double mean(final double[] t); static double variance(final double[] t); static double standardDeviation(final double[] t); static double[] normalizeByStandardDeviation(final double[] t);  }
@Test public void sortIndexesTest() { double[] vector = new double[] { 4, 2, 6 }; double[] vector2 = new double[] { 2, 4, 6 }; List<Integer> result1 = TimeSeriesUtil.sortIndexes(vector, true); List<Integer> result1Inv = TimeSeriesUtil.sortIndexes(vector, false); Assert.assertEquals(Arrays.asList(1, 0, 2), result1); Assert.assertEquals(Arrays.asList(2, 0, 1), result1Inv); List<Integer> result2 = TimeSeriesUtil.sortIndexes(vector2, true); Assert.assertEquals(Arrays.asList(0, 1, 2), result2); }