// Path: src/main/java/ro/hasna/ts/math/distribution/NormalDistributionDivider.java
// public class NormalDistributionDivider implements DistributionDivider {
//     private static final long serialVersionUID = -909800668897655203L;
// 
//     @Override
//     public double[] getBreakpoints(int areas) {
//         if (areas < 2) {
//             throw new NumberIsTooSmallException(areas, 2, true);
//         }
// 
//         NormalDistribution normalDistribution = new NormalDistribution();
//         int len = areas - 1;
//         double[] result = new double[len];
//         double searchArea = 1.0 / areas;
//         for (int i = 0; i < len; i++) {
//             result[i] = normalDistribution.inverseCumulativeProbability(searchArea * (i + 1));
//         }
// 
//         return result;
//     }
// }
// 
// Path: src/main/java/ro/hasna/ts/math/normalization/ZNormalizer.java
// public class ZNormalizer implements Normalizer {
//     private static final long serialVersionUID = 6446811014325682141L;
//     private final Mean mean;
//     private final StandardDeviation standardDeviation;
// 
//     public ZNormalizer() {
//         this(new Mean(), new StandardDeviation(false));
//     }
// 
//     /**
//      * Creates a new instance of this class with the given mean and standard deviation algorithms.
//      *
//      * @param mean              the mean
//      * @param standardDeviation the standard deviation
//      */
//     public ZNormalizer(final Mean mean, final StandardDeviation standardDeviation) {
//         this.mean = mean;
//         this.standardDeviation = standardDeviation;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public double[] normalize(double[] values) {
//         double m = mean.evaluate(values);
//         double sd = standardDeviation.evaluate(values, m);
// 
//         int length = values.length;
//         double[] normalizedValues = new double[length];
//         for (int i = 0; i < length; i++) {
//             normalizedValues[i] = (values[i] - m) / sd;
//         }
//         return normalizedValues;
//     }
// }
// 
// Path: src/main/java/ro/hasna/ts/math/type/SaxPair.java
// @Data
// public class SaxPair {
//     /**
//      * The symbol value for the segment.
//      */
//     private final int symbol;
//     /**
//      * The size of the alphabet used by the symbol.
//      */
//     private final int alphabetSize;
// }


import org.apache.commons.math3.exception.DimensionMismatchException;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import ro.hasna.ts.math.distribution.NormalDistributionDivider;
import ro.hasna.ts.math.normalization.ZNormalizer;
import ro.hasna.ts.math.type.SaxPair;
import java.util.Random;
/*
 * Copyright 2015 Octavian Hasna
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ro.hasna.ts.math.representation;




public class IndexableSymbolicAggregateApproximationTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Test
    public void testConstructorException() throws Exception {
        thrown.expect(DimensionMismatchException.class);
        thrown.expectMessage("5 != 4");

        new IndexableSymbolicAggregateApproximation(4, new int[5]);
    }

    @Test
    public void testTransformToSaxPairArray1() throws Exception {
        double[] list = new double[64];
        for (int i = 0; i < 32; i++) {
            list[i] = i;
        }
        for (int i = 32; i < 64; i++) {
            list[i] = 64 - i;
        }
        int[] alphabetSizes = new int[9];
        for (int i = 0; i < 9; i++) {
            alphabetSizes[i] = 3;
        }
// Path: src/main/java/ro/hasna/ts/math/distribution/NormalDistributionDivider.java
// public class NormalDistributionDivider implements DistributionDivider {
//     private static final long serialVersionUID = -909800668897655203L;
// 
//     @Override
//     public double[] getBreakpoints(int areas) {
//         if (areas < 2) {
//             throw new NumberIsTooSmallException(areas, 2, true);
//         }
// 
//         NormalDistribution normalDistribution = new NormalDistribution();
//         int len = areas - 1;
//         double[] result = new double[len];
//         double searchArea = 1.0 / areas;
//         for (int i = 0; i < len; i++) {
//             result[i] = normalDistribution.inverseCumulativeProbability(searchArea * (i + 1));
//         }
// 
//         return result;
//     }
// }
// 
// Path: src/main/java/ro/hasna/ts/math/normalization/ZNormalizer.java
// public class ZNormalizer implements Normalizer {
//     private static final long serialVersionUID = 6446811014325682141L;
//     private final Mean mean;
//     private final StandardDeviation standardDeviation;
// 
//     public ZNormalizer() {
//         this(new Mean(), new StandardDeviation(false));
//     }
// 
//     /**
//      * Creates a new instance of this class with the given mean and standard deviation algorithms.
//      *
//      * @param mean              the mean
//      * @param standardDeviation the standard deviation
//      */
//     public ZNormalizer(final Mean mean, final StandardDeviation standardDeviation) {
//         this.mean = mean;
//         this.standardDeviation = standardDeviation;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public double[] normalize(double[] values) {
//         double m = mean.evaluate(values);
//         double sd = standardDeviation.evaluate(values, m);
// 
//         int length = values.length;
//         double[] normalizedValues = new double[length];
//         for (int i = 0; i < length; i++) {
//             normalizedValues[i] = (values[i] - m) / sd;
//         }
//         return normalizedValues;
//     }
// }
// 
// Path: src/main/java/ro/hasna/ts/math/type/SaxPair.java
// @Data
// public class SaxPair {
//     /**
//      * The symbol value for the segment.
//      */
//     private final int symbol;
//     /**
//      * The size of the alphabet used by the symbol.
//      */
//     private final int alphabetSize;
// }


// Path: src/test/java/ro/hasna/ts/math/representation/IndexableSymbolicAggregateApproximationTest.java
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import ro.hasna.ts.math.distribution.NormalDistributionDivider;
import ro.hasna.ts.math.normalization.ZNormalizer;
import ro.hasna.ts.math.type.SaxPair;
import java.util.Random;

/*
 * Copyright 2015 Octavian Hasna
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ro.hasna.ts.math.representation;




public class IndexableSymbolicAggregateApproximationTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Test
    public void testConstructorException() throws Exception {
        thrown.expect(DimensionMismatchException.class);
        thrown.expectMessage("5 != 4");

        new IndexableSymbolicAggregateApproximation(4, new int[5]);
    }

    @Test
    public void testTransformToSaxPairArray1() throws Exception {
        double[] list = new double[64];
        for (int i = 0; i < 32; i++) {
            list[i] = i;
        }
        for (int i = 32; i < 64; i++) {
            list[i] = 64 - i;
        }
        int[] alphabetSizes = new int[9];
        for (int i = 0; i < 9; i++) {
            alphabetSizes[i] = 3;
        }
        SaxPair[] expected = new SaxPair[9];