use of de.lab4inf.math.Differentiable in project symja_android_library by axkr.
the class ProbabilityDistribution method quantileFischer.
/**
* Calculate the quantile xp for the student distribution. E.g. if p=cdf(xp) return xp.
*
* @param n 1.st degree of freedom for the Fischer f-function
* @param m 2.nd degree of freedom for the Fischer f-function
* @param p the cdf
* @return xp with cdf(xp)=p
*/
public static double quantileFischer(final int n, final int m, final double p) {
checkProbabilty(p);
double x;
// if(p<0.5) return 1.0/quantileFischer(m,n,1-p);
// create the error function err(x) = cdf(x) - p
// used for the Newton iteration.
final Differentiable fct = new FischerError(n, m, p);
final double x0 = 0, x1 = 1, f0 = fct.f(x0), f1 = fct.f(x1);
if (f0 == 0) {
return x0;
} else if (f1 == 0) {
return x1;
}
// find an initial starting guess
x = 1;
x = quantile(x, fct);
return x;
}
Aggregations