@Test public void testChisquareInverseCdf() { logger.info("ChisquareInverseCdf"); double p = 0.32; int df = 10; double expResult = 11.498788492223; double result = ContinuousDistributions.chisquareInverseCdf(p, df); assertEquals(expResult, result, Constants.DOUBLE_ACCURACY_HIGH); }
public static double chisquareInverseCdf(double p, int df) { final double CHI_EPSILON = 0.000001; final double CHI_MAX = 99999.0; double minchisq = 0.0; double maxchisq = CHI_MAX; if (p <= 0.0) { return CHI_MAX; } else if (p >= 1.0) { return 0.0; } double chisqval = df/Math.sqrt(p); while ((maxchisq - minchisq) > CHI_EPSILON) { if (1-chisquareCdf(chisqval, df) < p) { maxchisq = chisqval; } else { minchisq = chisqval; } chisqval = (maxchisq + minchisq) * 0.5; } return chisqval; }
ContinuousDistributions { public static double chisquareInverseCdf(double p, int df) { final double CHI_EPSILON = 0.000001; final double CHI_MAX = 99999.0; double minchisq = 0.0; double maxchisq = CHI_MAX; if (p <= 0.0) { return CHI_MAX; } else if (p >= 1.0) { return 0.0; } double chisqval = df/Math.sqrt(p); while ((maxchisq - minchisq) > CHI_EPSILON) { if (1-chisquareCdf(chisqval, df) < p) { maxchisq = chisqval; } else { minchisq = chisqval; } chisqval = (maxchisq + minchisq) * 0.5; } return chisqval; } }
ContinuousDistributions { public static double chisquareInverseCdf(double p, int df) { final double CHI_EPSILON = 0.000001; final double CHI_MAX = 99999.0; double minchisq = 0.0; double maxchisq = CHI_MAX; if (p <= 0.0) { return CHI_MAX; } else if (p >= 1.0) { return 0.0; } double chisqval = df/Math.sqrt(p); while ((maxchisq - minchisq) > CHI_EPSILON) { if (1-chisquareCdf(chisqval, df) < p) { maxchisq = chisqval; } else { minchisq = chisqval; } chisqval = (maxchisq + minchisq) * 0.5; } return chisqval; }  }
ContinuousDistributions { public static double chisquareInverseCdf(double p, int df) { final double CHI_EPSILON = 0.000001; final double CHI_MAX = 99999.0; double minchisq = 0.0; double maxchisq = CHI_MAX; if (p <= 0.0) { return CHI_MAX; } else if (p >= 1.0) { return 0.0; } double chisqval = df/Math.sqrt(p); while ((maxchisq - minchisq) > CHI_EPSILON) { if (1-chisquareCdf(chisqval, df) < p) { maxchisq = chisqval; } else { minchisq = chisqval; } chisqval = (maxchisq + minchisq) * 0.5; } return chisqval; }  static double chisquareCdf(double x, int df); static double gaussCdf(double z); static double gamma(double x); static double logGamma(double Z); static double studentsCdf(double x, int df); static double exponentialCdf(double x, double lamda); static double betaCdf(double x, double a, double b); static double fCdf(double x, int f1, int f2); static double gammaCdf(double x, double a, double b); static double uniformCdf(double x, double a, double b); static double kolmogorov(double z); static double gaussInverseCdf(double p); static double chisquareInverseCdf(double p, int df); static double normalQuantile(double p, double mu, double sigma); static double dirichletPdf(double[] pi, double[] ai); static double dirichletPdf(double[] pi, double a); static double[] multinomialGaussianSample(double[] mean, double[][] covariance); static double multinomialGaussianPdf(double[] mean, double[][] covariance, double[] x); }
ContinuousDistributions { public static double chisquareInverseCdf(double p, int df) { final double CHI_EPSILON = 0.000001; final double CHI_MAX = 99999.0; double minchisq = 0.0; double maxchisq = CHI_MAX; if (p <= 0.0) { return CHI_MAX; } else if (p >= 1.0) { return 0.0; } double chisqval = df/Math.sqrt(p); while ((maxchisq - minchisq) > CHI_EPSILON) { if (1-chisquareCdf(chisqval, df) < p) { maxchisq = chisqval; } else { minchisq = chisqval; } chisqval = (maxchisq + minchisq) * 0.5; } return chisqval; }  static double chisquareCdf(double x, int df); static double gaussCdf(double z); static double gamma(double x); static double logGamma(double Z); static double studentsCdf(double x, int df); static double exponentialCdf(double x, double lamda); static double betaCdf(double x, double a, double b); static double fCdf(double x, int f1, int f2); static double gammaCdf(double x, double a, double b); static double uniformCdf(double x, double a, double b); static double kolmogorov(double z); static double gaussInverseCdf(double p); static double chisquareInverseCdf(double p, int df); static double normalQuantile(double p, double mu, double sigma); static double dirichletPdf(double[] pi, double[] ai); static double dirichletPdf(double[] pi, double a); static double[] multinomialGaussianSample(double[] mean, double[][] covariance); static double multinomialGaussianPdf(double[] mean, double[][] covariance, double[] x);  }