3 * Copyright (C) 2002 Przemyslaw Sliwa and Jason H. Stover.
4 * Copyright (C) 2006, 2007 Brian Gough
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or (at
9 * your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22 #include <gsl/gsl_cdf.h>
23 #include <gsl/gsl_math.h>
24 #include <gsl/gsl_errno.h>
29 gsl_cdf_fdist_Pinv (const double P, const double nu1, const double nu2)
36 CDF_ERROR ("P < 0.0", GSL_EDOM);
40 CDF_ERROR ("P > 1.0", GSL_EDOM);
44 CDF_ERROR ("nu1 < 1", GSL_EDOM);
48 CDF_ERROR ("nu2 < 1", GSL_EDOM);
53 y = gsl_cdf_beta_Pinv (P, nu1 / 2.0, nu2 / 2.0);
55 result = nu2 * y / (nu1 * (1.0 - y));
59 y = gsl_cdf_beta_Qinv (P, nu2 / 2.0, nu1 / 2.0);
61 result = nu2 * (1 - y) / (nu1 * y);
68 gsl_cdf_fdist_Qinv (const double Q, const double nu1, const double nu2)
75 CDF_ERROR ("Q < 0.0", GSL_EDOM);
79 CDF_ERROR ("Q > 1.0", GSL_EDOM);
83 CDF_ERROR ("nu1 < 1", GSL_EDOM);
87 CDF_ERROR ("nu2 < 1", GSL_EDOM);
92 y = gsl_cdf_beta_Qinv (Q, nu1 / 2.0, nu2 / 2.0);
94 result = nu2 * y / (nu1 * (1.0 - y));
98 y = gsl_cdf_beta_Pinv (Q, nu2 / 2.0, nu1 / 2.0);
100 result = nu2 * (1 - y) / (nu1 * y);