I need to find PHP code that, given a probability (eg 80%), and a number of degrees of freedom (eg 9) returns the t-distribution, as in the chart at the bottom of this page:

http://en.wikipedia.org/wiki/T-distribution. (eg, for p=80%, df=9, the code would therefore return 0.883.)

what I really want to do is slightly more involved, namely for a given probability, and given a group of n values, and a given max range R, return:

1) the mean m of the n values

2) the standard deviation s of the n values (which can be calculated using the formula following "Estimating population standard deviation from sample standard deviation" on this page:

http://en.wikipedia.org/wiki/Standard_deviation
3) the number of degrees of freedom, d = n - 1

4) the standard error of the mean, sigma = s/((n)^(1/2))

5) the upper acceptable error bound b = m + Rm

6) the critical t value beyond which error is too high, T= (b - m)/sigma

7) the probability corresponding to this T given d

The seventh thing I want to return is the real problem, since I don't know how to calculate a t value from a probability and I've just been using the table.

I found a couple of bits of code that claim to do t-distributions, but since I don't know how object oriented PHP works, I'm not sure how to extract the part I need, or even how to use them. What I want to do is kind of backwards, because normally you calculate Rm for a known t, whereas I want to calculate t given a value for R.

Links to the t-distribution PHP I found:

http://www.multistat.de/source.php?file=t.php
(this one is an archive of a bunch of different probability classes, including one for t-distribution)

http://www.google.com/url?sa=t&ct=res&cd=1&url=http%3A%2F%2Fwww.phpmath.com%2Fbuild02%2Fdocs%2Fdownload.php%3Fop%3Ddownload&ei=LxCwRubnHaLSep-D0fsL&usg=AFQjCNGi4m7VjRsDnOuFl7vrWzG3otj6HQ&sig2=jVu-4ObjE_RFOMS6R-KzEA
All I really need is a function that will return a t-value given a probability and number of degrees of freedom.

The php documentation page is here: http://www.php.net/manual/en/function.stats-cdf-t.php

there is a list of other statistics functions here: http://www.php.net/manual/en/ref.stats.php