// Path: src/main/java/ro/hasna/ts/math/util/TimeSeriesPrecision.java
// public class TimeSeriesPrecision {
//     public static final double EPSILON = FastMath.pow(2, -30);
// 
//     /**
//      * Private constructor.
//      */
//     private TimeSeriesPrecision() {
//     }
// }


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.util.TimeSeriesPrecision;
        double[] v = {1, 1, 2, 2, 3, 3, 4, 4, 5};
        double[] w = {0.05, 0.1, 0.7, 0.1, 0.05};
        double[] expected = {1, 1, 1.9, 2.1, 2.9, 3.1, 3.9, 4, 5};

        Filter filter = new MovingAverageFilter(2, true, w);
        double[] result = filter.filter(v);

        Assert.assertArrayEquals(expected, result, TimeSeriesPrecision.EPSILON);
    }

    @Test
    public void testFilterNonSymmetricWithoutWeights() throws Exception {
        double[] v = {1, 1, 2, 2, 3, 3, 4, 4, 5};
        double[] expected = {1, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5};

        Filter filter = new MovingAverageFilter(2, false, null);
        double[] result = filter.filter(v);

        Assert.assertArrayEquals(expected, result, TimeSeriesPrecision.EPSILON);
    }

    @Test
    public void testFilterNonSymmetricWithWeights() throws Exception {
        double[] v = {1, 1, 2, 2, 3, 3, 4, 4, 5};
        double[] w = {0.4, 0.6};
        double[] expected = {1, 1, 1.6, 2, 2.6, 3, 3.6, 4, 4.6};

        Filter filter = new MovingAverageFilter(2, false, w);
        double[] result = filter.filter(v);

// Path: src/main/java/ro/hasna/ts/math/util/TimeSeriesPrecision.java
// public class TimeSeriesPrecision {
//     public static final double EPSILON = FastMath.pow(2, -30);
// 
//     /**
//      * Private constructor.
//      */
//     private TimeSeriesPrecision() {
//     }
// }


// Path: src/test/java/ro/hasna/ts/math/filter/MovingAverageFilterTest.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.util.TimeSeriesPrecision;

        double[] v = {1, 1, 2, 2, 3, 3, 4, 4, 5};
        double[] w = {0.05, 0.1, 0.7, 0.1, 0.05};
        double[] expected = {1, 1, 1.9, 2.1, 2.9, 3.1, 3.9, 4, 5};

        Filter filter = new MovingAverageFilter(2, true, w);
        double[] result = filter.filter(v);

        Assert.assertArrayEquals(expected, result, TimeSeriesPrecision.EPSILON);
    }

    @Test
    public void testFilterNonSymmetricWithoutWeights() throws Exception {
        double[] v = {1, 1, 2, 2, 3, 3, 4, 4, 5};
        double[] expected = {1, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5};

        Filter filter = new MovingAverageFilter(2, false, null);
        double[] result = filter.filter(v);

        Assert.assertArrayEquals(expected, result, TimeSeriesPrecision.EPSILON);
    }

    @Test
    public void testFilterNonSymmetricWithWeights() throws Exception {
        double[] v = {1, 1, 2, 2, 3, 3, 4, 4, 5};
        double[] w = {0.4, 0.6};
        double[] expected = {1, 1, 1.6, 2, 2.6, 3, 3.6, 4, 4.6};

        Filter filter = new MovingAverageFilter(2, false, w);
        double[] result = filter.filter(v);

        Assert.assertArrayEquals(expected, result, TimeSeriesPrecision.EPSILON);