数学统计,如何计算预设

数学统计,如何计算预设

问题描述:

Imagine I have a table like this :

month-year varchar
nbr integer

values :

[01-2014,5],[02-2014,110],[03-2014,154],[04-2014,110]

Imagine we are the 15th of april. This datas are displayed on a linear graph. If I display the real value for the month of april the line will be down. What I would like is to display the trend rather than the real value for the current month.

I tought about doing something like this :

(5+110+154+110) / (3 + (15/30.5)) = 108

Where "3" is the number of month passed, "30.5" is the average number of days by month, and "15" is the number of days passed for the current month. This is wrong because it's lower than the real value.

I'm pretty sure there is a more formal way to do this, but as you can see I don't know a lot about statistics and trends. I tought about other ways but they are not very convincing.

Can you help me ?

NB: in reality I can get the count number by day, even by hours or minutes. I just count in mysql the number of entries and I have a date-time column. I described the table with month and year in order to make myself clear for the purpose of this example.

想象一下,我有一个这样的表: p>

  month- 年varchar 
nbr整数
  code>  pre> 
 
 

值: p>

  [01-2014,5],[02-2014  ,110],[03-2014,154],[04-2014,110] 
  code>  pre> 
 
 

想象一下,我们是4月15日。 这个数据显示在 一个线性图。 如果我显示4月份的实际价值线将会下降。 我想要的是显示趋势而不是当月的实际价值。 p>

我想做类似的事情: p>

 (5 + 110 + 154 + 110)/(3 +(15 / 30.5))= 108 
  代码>  pre> 
 
 

其中“3”是月份的通过次数,“30.5”是按月份的平均天数,“15”是当月通过的天数 。 这是错误的,因为它低于实际价值。 p>

我很确定有更正式的方法可以做到这一点,但正如你所看到的,我对统计数据和趋势知之甚少。 我想采取其他方式,但不是很有说服力。 p>

你能帮助我吗? p>

注意:实际上我可以按天获得计数,甚至是几小时或几分钟。 我只计算mysql的条目数,我有一个日期时间列。 我描述了包含月份和年份的表格,以便在本例中明确说明。 p> div>

What you are trying to calculate is called a moving average.

You have a slight bug in your calculation. The formula should be:

(5+110+154+110) / (3 + (15/30.5))
                        ^^^^^^^

You need to decide how many months back to include in your moving average.