Boost logo

Boost :

From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2001-06-11 12:30:13


Is anyone interested in statistical functions for
Students's T, Fisher F, Chisq, their inverses,
and functions needed to generate them?

There is a collection of C functions which are
generated from FORTRAN (UGH!) by Barry Brown et al
at Univerisity of Texas dated 1997. The key work
is based on Didinto AR and Morris AH, Navel Surface Weapons Viginia
ACM TOMS 18 (1993) 360 -373

The code for CDCFLIB (Double-precision Cumulative Distribution Functions
Library.
is anon ftp from

odin.mda.uth.tmc.edu in /pub/unix/dfdflib.c.tar.z

These form part of the bottomless pit of working FORTRAN subroutines,
and are probably state of the art (until the NIST produce some
new version - promised in a few years, but language uncertain).

There are some potential licencing problems, but I feel
these may be surmoutable to meet the boost licence.

However the code is definitely C, and the format very ugly, for example:

void cdfchi(int* which, double* p, double* q, double* x, int* status,
double* bound)

which controls what is calculated and what is 'returned'.
status tells you if it worked OK, or what bound was exceeded, or ?

whereas the format most users would expect from Stats packages:
(for example in MAthCDF a Perl packaging of this code, MathCAD, StatsDirect
...)

is double pChisqr(double x, double df); // Probability of x and degrees of
freedom

and double qChisqr(double p, double df); // value of chisqr from
probability p and df.

(similarly for the other functions).

Re-packaging C++ style is easy enough,
but I would like guidance on how to handle the exceptional
conditions.

For example, if the probability is outside the range 0 to 1,
the result cannot be calculated because the parameter is wrong.

Should this be handled using exceptions, and if so exactly how, showing
as much info as possible. In this case, p is out of range 0 to 1 and
its erroneous value is useful. In other cases, other parameters can be
wrong (negative degrees of freedom), or the calculation itself can fail.
Worked examples please!

Should perhaps the functions be templated for float, double and long double?
(I am not sure about the internal computational implications of this).

Thanks

Paul

PS A C++ version of this could use/demo math_constants!

Dr Paul A Bristow, hetp Chromatography
Prizet Farmhouse
Kendal, Cumbria
LA8 8AB UK
+44 1539 561830
mailto:pbristow_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk