亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? movingaverage.java

?? jfreechart1.0.1 jsp繪制圖表的開發包
?? JAVA
字號:
/* ===========================================================
 * JFreeChart : a free chart library for the Java(tm) platform
 * ===========================================================
 *
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 *
 * This library is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by 
 * the Free Software Foundation; either version 2.1 of the License, or 
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
 * USA.  
 *
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 * in the United States and other countries.]
 *
 * ------------------
 * MovingAverage.java
 * ------------------
 * (C) Copyright 2003-2005, by Object Refinery Limited.
 *
 * Original Author:  David Gilbert (for Object Refinery Limited);
 * Contributor(s):   Benoit Xhenseval;
 *
 * $Id: MovingAverage.java,v 1.5.2.1 2005/10/25 21:35:24 mungady Exp $
 *
 * Changes
 * -------
 * 28-Jan-2003 : Version 1 (DG);
 * 10-Mar-2003 : Added createPointMovingAverage() method contributed by Benoit 
 *               Xhenseval (DG);
 * 01-Aug-2003 : Added new method for TimeSeriesCollection, and fixed bug in 
 *               XYDataset method (DG);
 * 15-Jul-2004 : Switched getX() with getXValue() and getY() with 
 *               getYValue() (DG);
 * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 
 *               release (DG);
 *
 */

package org.jfree.data.time;

import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

/**
 * A utility class for calculating moving averages of time series data.
 */
public class MovingAverage {

    /**
     * Creates a new {@link TimeSeriesCollection} containing a moving average 
     * series for each series in the source collection.
     * 
     * @param source  the source collection.
     * @param suffix  the suffix added to each source series name to create the
     *                corresponding moving average series name.
     * @param periodCount  the number of periods in the moving average 
     *                     calculation.
     * @param skip  the number of initial periods to skip.
     * 
     * @return A collection of moving average time series.
     */
    public static TimeSeriesCollection createMovingAverage(
        TimeSeriesCollection source, String suffix, int periodCount,
        int skip) {
    
        // check arguments
        if (source == null) {
            throw new IllegalArgumentException(
                "MovingAverage.createMovingAverage() : null source."
            );
        }

        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;
        
    }
    
    /**
     * Creates a new {@link TimeSeries} containing moving average values for 
     * the given series.  If the series is empty (contains zero items), the 
     * result is an empty series.
     *
     * @param source  the source series.
     * @param name  the name of the new series.
     * @param periodCount  the number of periods used in the average 
     *                     calculation.
     * @param skip  the number of initial periods to skip.
     *
     * @return The moving average series.
     */
    public static TimeSeries createMovingAverage(TimeSeries source,
                                                 String name,
                                                 int periodCount,
                                                 int skip) {

        // check arguments
        if (source == null) {
            throw new IllegalArgumentException("Null source.");
        }

        if (periodCount < 1) {
            throw new IllegalArgumentException(
                "periodCount must be greater than or equal to 1."
            );

        }

        TimeSeries result = new TimeSeries(name, source.getTimePeriodClass());

        if (source.getItemCount() > 0) {

            // if the initial averaging period is to be excluded, then 
            // calculate the index of the
            // first data item to have an average calculated...
            long firstSerial 
                = source.getDataItem(0).getPeriod().getSerialIndex() + skip;

            for (int i = source.getItemCount() - 1; i >= 0; i--) {

                // get the current data item...
                TimeSeriesDataItem current = source.getDataItem(i);
                RegularTimePeriod period = current.getPeriod();
                long serial = period.getSerialIndex();

                if (serial >= firstSerial) {
                    // work out the average for the earlier values...
                    int n = 0;
                    double sum = 0.0;
                    long serialLimit = period.getSerialIndex() - periodCount;
                    int offset = 0;
                    boolean finished = false;

                    while ((offset < periodCount) && (!finished)) {
                        if ((i - offset) >= 0) {
                            TimeSeriesDataItem item 
                                = source.getDataItem(i - offset);
                            RegularTimePeriod p = item.getPeriod();
                            Number v = item.getValue();
                            long currentIndex = p.getSerialIndex();
                            if (currentIndex > serialLimit) {
                                if (v != null) {
                                    sum = sum + v.doubleValue();
                                    n = n + 1;
                                }
                            }
                            else {
                                finished = true;
                            }
                        }
                        offset = offset + 1;
                    }
                    if (n > 0) {
                        result.add(period, sum / n);
                    }
                    else {
                        result.add(period, null);
                    }
                }

            }
        }

        return result;

    }

    /**
     * Creates a new {@link TimeSeries} containing moving average values for 
     * the given series, calculated by number of points (irrespective of the 
     * 'age' of those points).  If the series is empty (contains zero items), 
     * the result is an empty series.
     * <p>
     * Developed by Benoit Xhenseval (www.ObjectLab.co.uk).
     *
     * @param source  the source series.
     * @param name  the name of the new series.
     * @param pointCount  the number of POINTS used in the average calculation 
     *                    (not periods!)
     *
     * @return The moving average series.
     */
    public static TimeSeries createPointMovingAverage(TimeSeries source,
                                                      String name, 
                                                      int pointCount) {

        // check arguments
        if (source == null) {
            throw new IllegalArgumentException("Null 'source'.");
        }

        if (pointCount < 2) {
            throw new IllegalArgumentException(
                "periodCount must be greater than or equal to 2."
            );
        }

        TimeSeries result = new TimeSeries(name, source.getTimePeriodClass());
        double rollingSumForPeriod = 0.0;
        for (int i = 0; i < source.getItemCount(); i++) {
            // get the current data item...
            TimeSeriesDataItem current = source.getDataItem(i);
            RegularTimePeriod period = current.getPeriod();
            rollingSumForPeriod += current.getValue().doubleValue();

            if (i > pointCount - 1) {
                // remove the point i-periodCount out of the rolling sum.
                TimeSeriesDataItem startOfMovingAvg 
                    = source.getDataItem(i - pointCount);
                rollingSumForPeriod 
                    -= startOfMovingAvg.getValue().doubleValue();
                result.add(period, rollingSumForPeriod / pointCount);
            }
            else if (i == pointCount - 1) {
                result.add(period, rollingSumForPeriod / pointCount);
            }
        }
        return result;
    }

    /**
     * Creates a new {@link XYDataset} containing the moving averages of each 
     * series in the <code>source</code> dataset.
     *
     * @param source  the source dataset.
     * @param suffix  the string to append to source series names to create 
     *                target series names.
     * @param period  the averaging period.
     * @param skip  the length of the initial skip period.
     *
     * @return The dataset.
     */
    public static XYDataset createMovingAverage(XYDataset source, String suffix,
                                                long period, final long skip) {

        return createMovingAverage(
            source, suffix, (double) period, (double) skip
        );
        
    }


    /**
     * Creates a new {@link XYDataset} containing the moving averages of each 
     * series in the <code>source</code> dataset.
     *
     * @param source  the source dataset.
     * @param suffix  the string to append to source series names to create 
     *                target series names.
     * @param period  the averaging period.
     * @param skip  the length of the initial skip period.
     *
     * @return The dataset.
     */
    public static XYDataset createMovingAverage(XYDataset source, String suffix,
                                                double period, double skip) {

        // check arguments
        if (source == null) {
            throw new IllegalArgumentException("Null source (XYDataset).");
        }
        
        XYSeriesCollection result = new XYSeriesCollection();

        for (int i = 0; i < source.getSeriesCount(); i++) {
            XYSeries s = createMovingAverage(
                source, i, source.getSeriesKey(i) + suffix, period, skip
            );
            result.addSeries(s);
        }

        return result;

    }

    /**
     * Creates a new {@link XYSeries} containing the moving averages of one 
     * series in the <code>source</code> dataset.
     *
     * @param source  the source dataset.
     * @param series  the series index (zero based).
     * @param name  the name for the new series.
     * @param period  the averaging period.
     * @param skip  the length of the initial skip period.
     *
     * @return The dataset.
     */
    public static XYSeries createMovingAverage(XYDataset source, 
                                               int series, String name,
                                               double period, double skip) {

                                               
        // check arguments
        if (source == null) {
            throw new IllegalArgumentException("Null source (XYDataset).");
        }

        if (period < Double.MIN_VALUE) {
            throw new IllegalArgumentException("period must be positive.");

        }

        if (skip < 0.0) {
            throw new IllegalArgumentException("skip must be >= 0.0.");

        }

        XYSeries result = new XYSeries(name);

        if (source.getItemCount(series) > 0) {

            // if the initial averaging period is to be excluded, then 
            // calculate the lowest x-value to have an average calculated...
            double first = source.getXValue(series, 0) + skip;

            for (int i = source.getItemCount(series) - 1; i >= 0; i--) {

                // get the current data item...
                double x = source.getXValue(series, i);

                if (x >= first) {
                    // work out the average for the earlier values...
                    int n = 0;
                    double sum = 0.0;
                    double limit = x - period;
                    int offset = 0;
                    boolean finished = false;

                    while (!finished) {
                        if ((i - offset) >= 0) {
                            double xx = source.getXValue(series, i - offset);
                            Number yy = source.getY(series, i - offset);
                            if (xx > limit) {
                                if (yy != null) {
                                    sum = sum + yy.doubleValue();
                                    n = n + 1;
                                }
                            }
                            else {
                                finished = true;
                            }
                        }
                        else {
                            finished = true;
                        }
                        offset = offset + 1;
                    }
                    if (n > 0) {
                        result.add(x, sum / n);
                    }
                    else {
                        result.add(x, null);
                    }
                }

            }
        }

        return result;

    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美成人午夜| 不卡视频在线观看| 欧美一区二区三区日韩| 日本午夜精品视频在线观看| 欧美日韩美女一区二区| 亚洲成人中文在线| 91麻豆精品国产91久久久久久久久 | 亚洲精品国产一区二区三区四区在线 | 久久亚洲二区三区| 夫妻av一区二区| ...av二区三区久久精品| 欧美在线免费观看视频| 亚洲动漫第一页| 欧美本精品男人aⅴ天堂| 国产一区二区三区免费播放| 国产精品网友自拍| 在线日韩av片| 精品中文字幕一区二区| 国产精品天美传媒| 欧美日韩亚洲国产综合| 另类调教123区| 亚洲国产精品国自产拍av| 一本大道久久a久久综合婷婷| 亚洲chinese男男1069| 精品国精品国产| 97se亚洲国产综合自在线不卡| 亚洲成人第一页| 久久久久9999亚洲精品| 在线精品视频一区二区三四| 免费人成精品欧美精品| 国产精品女同一区二区三区| 欧美优质美女网站| 激情五月婷婷综合网| 欧美美女喷水视频| 精品午夜久久福利影院| 亚洲色图.com| 欧美日本一区二区在线观看| 免费看日韩a级影片| 久久亚洲精品小早川怜子| 国产69精品久久99不卡| 亚洲天天做日日做天天谢日日欢 | www.欧美色图| 亚洲第四色夜色| 精品日韩在线一区| 99国产精品久| 久久国产欧美日韩精品| 国产偷国产偷亚洲高清人白洁| 99久久婷婷国产| 日韩精品电影一区亚洲| 久久嫩草精品久久久精品| 91视频在线看| 久久99久国产精品黄毛片色诱| 国产欧美精品区一区二区三区| 色综合天天狠狠| 裸体一区二区三区| 日韩理论片在线| 欧美撒尿777hd撒尿| 麻豆国产精品777777在线| 欧美韩国一区二区| 在线观看视频一区二区| 国产剧情一区二区三区| 亚洲国产精品嫩草影院| 国产精品午夜在线观看| 欧美高清视频不卡网| 成人久久18免费网站麻豆| 秋霞电影网一区二区| 亚洲日本韩国一区| 亚洲精品一区二区三区精华液 | 欧美大黄免费观看| 在线观看亚洲精品| 成人av先锋影音| 国内偷窥港台综合视频在线播放| 亚洲男女毛片无遮挡| 6080日韩午夜伦伦午夜伦| 国产成人av影院| 亚洲超碰精品一区二区| 伊人色综合久久天天人手人婷| 精品国产a毛片| 欧美一区二区美女| 欧美色图片你懂的| 91在线无精精品入口| 国产乱码字幕精品高清av| 日韩国产在线观看| 亚洲高清不卡在线| 亚洲精品日日夜夜| 最近日韩中文字幕| 国产精品久久久久婷婷二区次| 欧美大尺度电影在线| 欧美日韩高清影院| 91精品福利视频| 91色综合久久久久婷婷| 丁香桃色午夜亚洲一区二区三区| 国产做a爰片久久毛片| 九九九久久久精品| 蜜桃视频一区二区| 日本va欧美va欧美va精品| 亚洲欧美视频一区| 中文字幕乱码一区二区免费| 欧美一区二区三区视频在线| 欧美一区二区二区| 欧美日韩不卡在线| 7777女厕盗摄久久久| 欧美精品三级在线观看| 国产精品色哟哟网站| 国产三级一区二区三区| 国产拍揄自揄精品视频麻豆| 亚洲国产成人在线| 中文字幕在线不卡一区二区三区| 国产日产欧美一区| 国产日韩欧美高清在线| 精品国产一二三| 亚洲精品在线免费观看视频| 国产视频一区二区在线| 蜜臀av亚洲一区中文字幕| 美国毛片一区二区三区| 国产原创一区二区| 成人av资源下载| 91久久国产最好的精华液| 91麻豆精品国产91久久久久久久久| 精品视频一区二区不卡| 精品国产三级a在线观看| 欧美激情一区二区三区四区| 亚洲乱码中文字幕综合| 午夜精品福利一区二区三区蜜桃| 蜜桃视频一区二区三区| 高清在线不卡av| 欧美视频日韩视频| 精品美女被调教视频大全网站| 国产精品乱码一区二区三区软件 | 亚洲综合网站在线观看| 麻豆精品精品国产自在97香蕉| 国产一区二区视频在线播放| www.色综合.com| 欧美精品在线观看播放| 国产午夜亚洲精品理论片色戒| 亚洲男人的天堂网| 国产一区激情在线| 一本大道久久a久久精品综合| 欧美丰满少妇xxxbbb| 2021中文字幕一区亚洲| 亚洲精品欧美激情| 国产成人亚洲综合a∨婷婷| 欧美亚日韩国产aⅴ精品中极品| 欧美r级在线观看| 亚洲人一二三区| 国产麻豆精品一区二区| 欧美三级电影一区| 国产精品久久久久久久久晋中| 亚洲高清视频在线| 国产一区二区三区美女| 欧美日韩一区二区欧美激情| 欧美激情一区不卡| 麻豆精品一区二区综合av| 中文字幕第一区| 蜜臀91精品一区二区三区| 欧美另类高清zo欧美| 国产精品亲子伦对白| 久久精品国产99| 欧美日韩一区二区在线观看 | 久久久精品黄色| 亚洲18色成人| 91视频观看视频| 久久综合色婷婷| 热久久久久久久| 欧美综合久久久| 国产精品国产三级国产aⅴ中文| 男人操女人的视频在线观看欧美| 日本精品视频一区二区三区| 欧美一区二区视频在线观看2020| 国产精品久久久久影院亚瑟| 国产电影一区二区三区| 精品裸体舞一区二区三区| 亚洲 欧美综合在线网络| 91在线观看视频| 亚洲欧美中日韩| 国产91丝袜在线观看| 精品免费国产一区二区三区四区| 亚洲国产精品影院| 色av一区二区| 亚洲欧美另类在线| 99国产欧美久久久精品| 国产精品国产自产拍高清av | 国产福利不卡视频| 久久理论电影网| 国产精品456| 久久综合网色—综合色88| 久久精品国产一区二区| 9191国产精品| 麻豆成人免费电影| 欧美tk—视频vk| 麻豆专区一区二区三区四区五区| 欧美亚一区二区| 三级不卡在线观看| 欧美日韩一区不卡| 日韩高清电影一区| 欧美一区二区三区在线看| 久久精品国产澳门| 国产午夜精品福利| a4yy欧美一区二区三区| ...av二区三区久久精品|