views:

56

answers:

3

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 would be the most statistically accurate method?

A: 

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.

Jhong
+1  A: 

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.

advait
and I dont think php can handle that kind of deep mathematical calculation. In the good ol days scientists use fortran for this, now there is Mathematica or Matlab.
marvin
It's actually quite possible in PHP, as it is in most languages. While languages and tools such as Matlab or R are specifically designed with language constructs for this type of activity, more generalised languages such as C or java or PHP are no less capable of performing the mathematics. PHPExcel, for eaxmple, has just such features built in as part of the package, written in pure PHP, in order to replicate Excel's features.
Mark Baker
A: 

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
casablanca