Calculating the $p$-value of an $F$- statistic I am trying to implement an algorithm for calculating $p$-values of $F$-tests and I need this method to be highly precise. It is easy to implement this with $z$- or $t$- tables, however I don't know how to do this with $F$-values. I have seen some online calculators that do this job, what method do they use? Interpolation of couple of $F$-tables would surely be unprecise. 
Any help would be appreciated. Thanks in advance
 A: More details than you probably want on the mathematics of the F distribution can be found here (and other places).  The formula for the pdf is there and the p-value is just the integral from your F-statistic to infinity of that function.  It also has the Cumulative distribution function for the F distribution and the p-value will just be one minus the cumulative up to your F statistic.  The cumulative function is expressed in terms of the incomplete beta distribution (with link if you want the details).  There may be implementations of the incomplete beta distribution already in Scheme that you could use (this would be fairly simple then), if not there are implementations in other languages (here is one location) that you could probably link to your Scheme program (I don't know Scheme enough to know about linking, but you should be able to find a way).
A: About Scheme libraries specifically, here are two GSL bindings that you might be interested in:


*

*Noel Welsh's fork of mzgsl.

*The Science collection, by Doug Williams, provides a collection of modules for numerical computing; it includes random number distributions, among others.


The second project is readily available on PLaneT if you use Racket. 
Here is an example that returns the $p$-value for the quantile $x=4.2$ of an ${\cal F}(2, 10)$ distribution ($p=0.047$): 
(require (planet williams/science/random-distributions/f-distribution))
(- 1 (f-distribution-cdf 4.2 2 10))

with the corresponding CDF
(require (planet williams/science/random-distributions/f-distribution-graphics))
(f-distribution-plot 2 10)


There are also some statistical functions available for Chicken Scheme (release branch 4). After having installed the required dependencies, e.g.
$ sudo chicken-install statistics

you will be able to do something like
(use statistics)
(f-significance 4.2 2 10 #:one-tailed? #t)

in the interactive Chicken shell (csi).
As pointed out by @cardinal, the Guile-numeric bindings look promising as it seems to provide a more integrated framework (with libfft and lapack support) for statistical computing. I have no time to test it presently but it is worth trying to.
A: Calculating the p-value for an F-Test is a quite straightforward job in every statistical programme. Consider for example r (r-project). Here's an example in R:
pf(F, df1=dfa, df2=dfb)

where F is the value from the statistic and dfa and dfb  are the degrees of freedom.
Hope this helps you!
