使用迭代值递增趋势分析 [英] Trend analysis using iterative value increments

查看:175
本文介绍了使用迭代值递增趋势分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经配置iReport的生成如下图:

We have configured iReport to generate the following graph:

真正的数据点为蓝色,趋势线是绿色的。这些问题包括:

The real data points are in blue, the trend line is green. The problems include:

  • 有太多的数据点的趋势线
  • 在趋势线不遵循Bezier曲线(样条)

问题的来源是用增量器类。增量器设置有数据点迭代。似乎没有有一种方法来获取一组数据。在code,计算趋势线如下所示:

The source of the problem is with the incrementer class. The incrementer is provided with the data points iteratively. There does not appear to be a way to get the set of data. The code that calculates the trend line looks as follows:

import java.math.BigDecimal;
import net.sf.jasperreports.engine.fill.*;

/**
 * Used by an iReport variable to increment its average.
 */
public class MovingAverageIncrementer
  implements JRIncrementer {
  private BigDecimal average;

  private int incr = 0;

  /**
   * Instantiated by the MovingAverageIncrementerFactory class.
   */
  public MovingAverageIncrementer() {
  }

  /**
   * Returns the newly incremented value, which is calculated by averaging
   * the previous value from the previous call to this method.
   * 
   * @param jrFillVariable Unused.
   * @param object New data point to average.
   * @param abstractValueProvider Unused.
   * @return The newly incremented value.
   */
  public Object increment( JRFillVariable jrFillVariable, Object object, 
                           AbstractValueProvider abstractValueProvider ) {
    BigDecimal value = new BigDecimal( ( ( Number )object ).doubleValue() );

    // Average every 10 data points
    //
    if( incr % 10 == 0 ) {
      setAverage( ( value.add( getAverage() ).doubleValue() / 2.0 ) );
    }

    incr++;

    return getAverage();
  }


  /**
   * Changes the value that is the moving average.
   * @param average The new moving average value.
   */
  private void setAverage( BigDecimal average ) {
    this.average = average;
  }

  /**
   * Returns the current moving average average.
   * @return Value used for plotting on a report.
   */
  protected BigDecimal getAverage() {
    if( this.average == null ) {
      this.average = new BigDecimal( 0 );
    }

    return this.average;
  }

  /** Helper method. */    
  private void setAverage( double d ) {
    setAverage( new BigDecimal( d ) );
  }
}

你会如何创建趋势线的更流畅,更准确地重新presentation?

How would you create a smoother and more accurate representation of the trend line?

推荐答案

这取决于你正在测量的项目的行为。这是一些移动(或变化)的可以建模的方式?

This depends on the behavior of the item you are measuring. Is this something that moves (or changes) in a manner that can be modeled?

如果该项目预计不会改变,那么你的趋势应该是整个样本集的基础平均值,而不仅仅是过去的两次测量。你可以使用这个贝叶斯定理。移动平均可以用简单的公式来计算增量

If the item is not expected to change, then your trend should be the underlying mean value of the entire sample set, not just the past two measurements. You can get this using Bayes theorem. The running average can be calculated incrementally using the simple formula

MTN1 =(MTN * N + X)/(N + 1)

Mtn1 = (Mtn * N + x) / (N+1)

其中x是测量在时间t + 1,MTN1是平均一个时刻t + 1,MTN是平均在时间t,而N是所采取时间t测量的次数。

where x is the measurement at time t+1, Mtn1 is the mean a time t+1, Mtn is the mean at time t, and N is the number of measurements taken by time t.

如果您测量变动的方式的项目,可以通过一些基本的公式pdicted $ P $,那么你可以使用的卡尔曼滤波器提供下一个点的基础上,previous最佳估计(最近)的测量和模型$ P ​​$ pdicted行为方程。

If the item you are measuring fluctuates in a manner that can be predicted by some underlying equation, then you can use a Kalman filter to provide a best estimate of the next point based on the previous (recent) measurements and the equation that models the predicted behavior.

作为一个起点,在贝叶斯估计的维基百科条目并卡尔曼滤波器会有所帮助。

As a starting point, the Wikipedia entry on Bayesian estimators and Kalman Filters will be helpful.

这篇关于使用迭代值递增趋势分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆