@Test public void test1() { TimeSeries source = createDailyTimeSeries1(); TimeSeries maverage = MovingAverage.createMovingAverage( source, "Moving Average", 3, 3 ); assertEquals(7, maverage.getItemCount()); double value = maverage.getValue(0).doubleValue(); assertEquals(14.1, value, EPSILON); value = maverage.getValue(1).doubleValue(); assertEquals(13.4, value, EPSILON); value = maverage.getValue(2).doubleValue(); assertEquals(14.433333333333, value, EPSILON); value = maverage.getValue(3).doubleValue(); assertEquals(14.933333333333, value, EPSILON); value = maverage.getValue(4).doubleValue(); assertEquals(19.8, value, EPSILON); value = maverage.getValue(5).doubleValue(); assertEquals(15.25, value, EPSILON); value = maverage.getValue(6).doubleValue(); assertEquals(12.5, value, EPSILON); }
public static TimeSeriesCollection createMovingAverage( TimeSeriesCollection source, String suffix, int periodCount, int skip) { if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } if (periodCount < 1) { throw new IllegalArgumentException("periodCount must be greater " + "than or equal to 1."); } TimeSeriesCollection result = new TimeSeriesCollection(); for (int i = 0; i < source.getSeriesCount(); i++) { TimeSeries sourceSeries = source.getSeries(i); TimeSeries maSeries = createMovingAverage(sourceSeries, sourceSeries.getKey() + suffix, periodCount, skip); result.addSeries(maSeries); } return result; }
MovingAverage { public static TimeSeriesCollection createMovingAverage( TimeSeriesCollection source, String suffix, int periodCount, int skip) { if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } if (periodCount < 1) { throw new IllegalArgumentException("periodCount must be greater " + "than or equal to 1."); } TimeSeriesCollection result = new TimeSeriesCollection(); for (int i = 0; i < source.getSeriesCount(); i++) { TimeSeries sourceSeries = source.getSeries(i); TimeSeries maSeries = createMovingAverage(sourceSeries, sourceSeries.getKey() + suffix, periodCount, skip); result.addSeries(maSeries); } return result; } }
MovingAverage { public static TimeSeriesCollection createMovingAverage( TimeSeriesCollection source, String suffix, int periodCount, int skip) { if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } if (periodCount < 1) { throw new IllegalArgumentException("periodCount must be greater " + "than or equal to 1."); } TimeSeriesCollection result = new TimeSeriesCollection(); for (int i = 0; i < source.getSeriesCount(); i++) { TimeSeries sourceSeries = source.getSeries(i); TimeSeries maSeries = createMovingAverage(sourceSeries, sourceSeries.getKey() + suffix, periodCount, skip); result.addSeries(maSeries); } return result; }  }
MovingAverage { public static TimeSeriesCollection createMovingAverage( TimeSeriesCollection source, String suffix, int periodCount, int skip) { if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } if (periodCount < 1) { throw new IllegalArgumentException("periodCount must be greater " + "than or equal to 1."); } TimeSeriesCollection result = new TimeSeriesCollection(); for (int i = 0; i < source.getSeriesCount(); i++) { TimeSeries sourceSeries = source.getSeries(i); TimeSeries maSeries = createMovingAverage(sourceSeries, sourceSeries.getKey() + suffix, periodCount, skip); result.addSeries(maSeries); } return result; }  static TimeSeriesCollection createMovingAverage(
            TimeSeriesCollection source, String suffix, int periodCount,
            int skip); static TimeSeries createMovingAverage(TimeSeries source,
            String name, int periodCount, int skip); static TimeSeries createPointMovingAverage(TimeSeries source,
            String name, int pointCount); static XYDataset createMovingAverage(XYDataset source, String suffix,
            long period, long skip); static XYDataset createMovingAverage(XYDataset source,
            String suffix, double period, double skip); static XYSeries createMovingAverage(XYDataset source,
            int series, String name, double period, double skip); }
MovingAverage { public static TimeSeriesCollection createMovingAverage( TimeSeriesCollection source, String suffix, int periodCount, int skip) { if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } if (periodCount < 1) { throw new IllegalArgumentException("periodCount must be greater " + "than or equal to 1."); } TimeSeriesCollection result = new TimeSeriesCollection(); for (int i = 0; i < source.getSeriesCount(); i++) { TimeSeries sourceSeries = source.getSeries(i); TimeSeries maSeries = createMovingAverage(sourceSeries, sourceSeries.getKey() + suffix, periodCount, skip); result.addSeries(maSeries); } return result; }  static TimeSeriesCollection createMovingAverage(
            TimeSeriesCollection source, String suffix, int periodCount,
            int skip); static TimeSeries createMovingAverage(TimeSeries source,
            String name, int periodCount, int skip); static TimeSeries createPointMovingAverage(TimeSeries source,
            String name, int pointCount); static XYDataset createMovingAverage(XYDataset source, String suffix,
            long period, long skip); static XYDataset createMovingAverage(XYDataset source,
            String suffix, double period, double skip); static XYSeries createMovingAverage(XYDataset source,
            int series, String name, double period, double skip);  }