@Test public void testQuantile() { System.out.println("quantile"); TDistribution instance = new TDistribution(20); instance.rand(); assertEquals(-3.551808, instance.quantile(0.001), 1E-6); assertEquals(-2.527977, instance.quantile(0.01), 1E-6); assertEquals(-1.325341, instance.quantile(0.1), 1E-6); assertEquals(-0.8599644, instance.quantile(0.2), 1E-6); assertEquals(0.0, instance.quantile(0.5), 1E-6); assertEquals(1.325341, instance.quantile(0.9), 1E-6); assertEquals(2.527977, instance.quantile(0.99), 1E-6); assertEquals(3.551808, instance.quantile(0.999), 1E-6); }
@Override public double quantile(double p) { if (p < 0.0 || p > 1.0) { throw new IllegalArgumentException("Invalid p: " + p); } double x = Beta.inverseRegularizedIncompleteBetaFunction(0.5 * nu, 0.5, 2.0 * Math.min(p, 1.0 - p)); x = Math.sqrt(nu * (1.0 - x) / x); return p >= 0.5 ? x : -x; }
TDistribution extends AbstractDistribution { @Override public double quantile(double p) { if (p < 0.0 || p > 1.0) { throw new IllegalArgumentException("Invalid p: " + p); } double x = Beta.inverseRegularizedIncompleteBetaFunction(0.5 * nu, 0.5, 2.0 * Math.min(p, 1.0 - p)); x = Math.sqrt(nu * (1.0 - x) / x); return p >= 0.5 ? x : -x; } }
TDistribution extends AbstractDistribution { @Override public double quantile(double p) { if (p < 0.0 || p > 1.0) { throw new IllegalArgumentException("Invalid p: " + p); } double x = Beta.inverseRegularizedIncompleteBetaFunction(0.5 * nu, 0.5, 2.0 * Math.min(p, 1.0 - p)); x = Math.sqrt(nu * (1.0 - x) / x); return p >= 0.5 ? x : -x; } TDistribution(int nu); }
TDistribution extends AbstractDistribution { @Override public double quantile(double p) { if (p < 0.0 || p > 1.0) { throw new IllegalArgumentException("Invalid p: " + p); } double x = Beta.inverseRegularizedIncompleteBetaFunction(0.5 * nu, 0.5, 2.0 * Math.min(p, 1.0 - p)); x = Math.sqrt(nu * (1.0 - x) / x); return p >= 0.5 ? x : -x; } TDistribution(int nu); @Override int length(); @Override double mean(); @Override double variance(); @Override double sd(); @Override double entropy(); @Override String toString(); @Override double rand(); @Override double p(double x); @Override double logp(double x); @Override double cdf(double x); @Override double quantile(double p); double cdf2tiled(double x); double quantile2tiled(double p); }
TDistribution extends AbstractDistribution { @Override public double quantile(double p) { if (p < 0.0 || p > 1.0) { throw new IllegalArgumentException("Invalid p: " + p); } double x = Beta.inverseRegularizedIncompleteBetaFunction(0.5 * nu, 0.5, 2.0 * Math.min(p, 1.0 - p)); x = Math.sqrt(nu * (1.0 - x) / x); return p >= 0.5 ? x : -x; } TDistribution(int nu); @Override int length(); @Override double mean(); @Override double variance(); @Override double sd(); @Override double entropy(); @Override String toString(); @Override double rand(); @Override double p(double x); @Override double logp(double x); @Override double cdf(double x); @Override double quantile(double p); double cdf2tiled(double x); double quantile2tiled(double p); final int nu; }