开发者

PHP Estimation Function

I am trying to calculate value $x in a number series based on an array of numbers (as $numbers).

Ex:

$numbers = array(1=>1000,2=>600,3=>500,4=>450,5=>425,6=>405,7=>400,8=>396);
function estimateNumber($x) {
  // function to estimate number $x in $numbers data set
}

What w开发者_如何学JAVAould be the most statistically accurate method?


What you're attempting to do is a large branch of mathematics called interpolation. Claiming one way is more "statistically accurate" than the other will probably spark religious wars. It all depends on what kind of data you're trying to interpolate.

Linear interpolation will be the most straightforward.


You need to decide if you want to fit a straight line or an n-th order polynomial. Maybe try some examples in Excel to give you an idea of which you need.


There is no single "most statistically accurate method". It depends on what you are estimating as well as previously observed values. Going by your existing set of values, it seems to be exponentially decreasing, and as you can see, by the 7th and 8th values, it's already reached a point where it decreases only by 5 and 4 respectively. You can expect this to further reduce by 3, 2 and 1, after which it would become almost constant, only changing a little in the decimal places.

This would be a fair approximation:

...
7  => 400
8  => 396
9  => 393
10 => 391
11 => 390
12 and above => 389.xxx
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜