Java 类org.jfree.data.time.MovingAverage 实例源码

项目:parabuild-ci    文件:MovingAverageTests.java   
/**
 * A test for the values calculated from a time series.
 */
public void test1() {
    final TimeSeries source = createDailyTimeSeries1();
    final TimeSeries maverage = MovingAverage.createMovingAverage(
        source, "Moving Average", 3, 3
    );

    // the moving average series has 7 items, the first three 
    // days (11, 12, 13 August are skipped)
    assertEquals(7, maverage.getItemCount());
    double value = maverage.getValue(0).doubleValue();
    assertTrue(NumberUtils.equal(value, 14.1));
    value = maverage.getValue(1).doubleValue();
    assertTrue(NumberUtils.equal(value, 13.4));
    value = maverage.getValue(2).doubleValue();
    assertTrue(NumberUtils.equal(value, 14.43333333333));
    value = maverage.getValue(3).doubleValue();
    assertTrue(NumberUtils.equal(value, 14.93333333333));
    value = maverage.getValue(4).doubleValue();
    assertTrue(NumberUtils.equal(value, 19.8));
    value = maverage.getValue(5).doubleValue();
    assertTrue(NumberUtils.equal(value, 15.25));
    value = maverage.getValue(6).doubleValue();
    assertTrue(NumberUtils.equal(value, 12.5));
}
项目:parabuild-ci    文件:MovingAverageTests.java   
/**
 * A test for the values calculated from a time series.
 */
public void test1() {
    TimeSeries source = createDailyTimeSeries1();
    TimeSeries maverage = MovingAverage.createMovingAverage(
        source, "Moving Average", 3, 3
    );

    // the moving average series has 7 items, the first three 
    // days (11, 12, 13 August are skipped)
    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);
}
项目:nabs    文件:MovingAverageTests.java   
/**
 * A test for the values calculated from a time series.
 */
public void test1() {
    TimeSeries source = createDailyTimeSeries1();
    TimeSeries maverage = MovingAverage.createMovingAverage(
        source, "Moving Average", 3, 3
    );

    // the moving average series has 7 items, the first three 
    // days (11, 12, 13 August are skipped)
    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);
}
项目:astor    文件:MovingAverageTests.java   
/**
 * A test for the values calculated from a time series.
 */
public void test1() {
    TimeSeries source = createDailyTimeSeries1();
    TimeSeries maverage = MovingAverage.createMovingAverage(
        source, "Moving Average", 3, 3
    );

    // the moving average series has 7 items, the first three
    // days (11, 12, 13 August are skipped)
    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);
}
项目:jrunalyzer    文件:MovingAverageConfigDecorator.java   
@Override
public XYDataset createDataset(Track track,
        Function<LinkedTrackPoint, ? extends Number> xFunc) {

    // source - the source collection.
    // suffix - the suffix added to each source series name to create the
    // corresponding moving average series name.
    // periodCount - the number of periods in the moving average
    // calculation.
    // skip - the number of initial periods to skip.
    XYDataset undecorated = super.createDataset(track, xFunc);
    return MovingAverage.createMovingAverage(undecorated, this.suffix,
            this.periodCount, this.skip);
}
项目:Data-and-Information-Visualization-Project    文件:MongoController.java   
public TimeSeries getTimeSerie(DataType t, DBObject groupOp, String groupNameX, String groupNameY, String cName, Boolean useMovingAverage) {
    long begin = new Date().getTime();

    // Query fetches collection t
    DBCollection c = getCollection(t);
    AggregationOutput ao = c.aggregate(groupOp);
    TimeSeries timeserie = new TimeSeries(cName);

    HashMap<Integer, Integer> valueMap = new HashMap<Integer, Integer>();
    List<Integer> xVals = new ArrayList<Integer>();
    for (DBObject dbo : ao.results()) {
        int x = (Integer) dbo.get(groupNameX);
        int y = (Integer) dbo.get(groupNameY);
        xVals.add(x);
        valueMap.put(x, y);
    }

    int min = Collections.min(xVals);
    int max = Collections.max(xVals);
    for (int i = min; i <= max; i += 60) {
        timeserie.add(new Minute(new Date(i * 1000L)), valueMap.get(i));
    }

    if (useMovingAverage) {
        timeserie = MovingAverage.createMovingAverage(timeserie, cName, 50, 100);
    }

    logger.info("Fetched slider backgroud data, DataType:" + t.toString() + ", query took " + (new Date().getTime() - begin) + " ms");

    return timeserie;
}
项目:magate    文件:ScenarioCommunityPlotter.java   
protected void plotPrint() {

        /*************** recentJob_CE Line chart ***************/
        this.readPrintPlotDataset();

        /*************** CE for all Line charts ***************/
        this.perScenarioTimeseriesCollection[0].addSeries(perScenarioTimeseries[6]);  // ce

        // Set plot
        this.perScenarioTimeseriesCollection[1].addSeries(perScenarioTimeseries[0]);  // arrived_job
        this.perScenarioTimeseriesCollection[1].addSeries(perScenarioTimeseries[1]);  // scheduling_job
        this.perScenarioTimeseriesCollection[1].addSeries(perScenarioTimeseries[2]);  // processing_job
        this.perScenarioTimeseriesCollection[1].addSeries(perScenarioTimeseries[3]);  // executed_job
        this.perScenarioTimeseriesCollection[1].addSeries(perScenarioTimeseries[4]);  // suspended_job

        TimeSeries meanExecutedJob = MovingAverage.createMovingAverage(perScenarioTimeseries[3], "mean of executed jobs", 10, 0);
        TimeSeries meanSuspendedJob = MovingAverage.createMovingAverage(perScenarioTimeseries[4], "mean of suspended jobs", 10, 0);

        this.perScenarioTimeseriesCollection[1].addSeries(meanExecutedJob);
        this.perScenarioTimeseriesCollection[1].addSeries(meanSuspendedJob);

        this.printChart = ChartFactory.createTimeSeriesChart(
            "Community Status Averaged Overview", // chart title
            "Date/Time",
            "Num. of jobs",
            this.perScenarioTimeseriesCollection[1],                     
            true,                       // include legend
            true,
            false
        );

//      this.printChart.addSubtitle(new TextTitle(MaGateParam.numberOfTotalNode + 
//              " nodes and " + MaGateParam.totalNumberOfJob + " jobs in total"));
        this.printChart.addSubtitle(new TextTitle(MaGateParam.currentScenarioId));

        XYPlot recentJobPlot = (XYPlot) this.printChart.getPlot();
        this.printChart.setBackgroundPaint(Color.white);
        recentJobPlot.setBackgroundPaint(Color.lightGray);
        recentJobPlot.setDomainGridlinePaint(Color.white);
        recentJobPlot.setRangeGridlinePaint(Color.white);

        // change the auto tick unit selection to integer units only...
        NumberAxis recentJobPlotRangeAxis = (NumberAxis) recentJobPlot.getRangeAxis();
        recentJobPlotRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

        XYLineAndShapeRenderer recentJobPlotlineRenderer = (XYLineAndShapeRenderer) recentJobPlot.getRenderer();
        recentJobPlotlineRenderer.setBaseShapesVisible(true);
        recentJobPlotlineRenderer.setBaseShapesFilled(true);

        DateAxis recentJobPlotlineDomainaxis = (DateAxis) recentJobPlot.getDomainAxis();
        recentJobPlotlineDomainaxis.setAutoRange(true);
//        recentJobPlotlineDomainaxis.setFixedAutoRange(1000.0 * 3600 * 24 * 1);  // 1 second * 3600 * 24 * 1 = 1 day
        recentJobPlotlineDomainaxis.setDateFormatOverride(new SimpleDateFormat("H,dd-MMM"));

        recentJobPlot.setDataset(1, this.perScenarioTimeseriesCollection[0]);
        NumberAxis recentJobPlotline_rangeAxis2 = new NumberAxis("Percentage");
        recentJobPlotline_rangeAxis2.setAutoRangeIncludesZero(false);
        recentJobPlot.setRenderer(1, new DefaultXYItemRenderer());
        recentJobPlot.setRangeAxis(1, recentJobPlotline_rangeAxis2);
        recentJobPlot.mapDatasetToRangeAxis(1, 1);

        recentJobPlot.getRenderer().setSeriesPaint(0, Color.BLACK); // arrival job
        recentJobPlot.getRenderer().setSeriesPaint(1, Color.BLUE); // scheduling job
        recentJobPlot.getRenderer().setSeriesPaint(2, Color.ORANGE); // processing job
        recentJobPlot.getRenderer().setSeriesPaint(3, Color.GREEN); // executed job
        recentJobPlot.getRenderer().setSeriesPaint(4, Color.GRAY); // suspended job
        recentJobPlot.getRenderer().setSeriesPaint(5, Color.RED); // CE
        recentJobPlot.getRenderer().setSeriesPaint(5, Color.MAGENTA); 

    }
项目:bitthief    文件:RawDownloadRate.java   
private TimeSeries createAverageSeries(TimeSeries timeSeries) {
  return MovingAverage.createMovingAverage(timeSeries, "5 Minute Average", 5 * 60, 0);
}