1 package JSci.maths.statistics; 2 3 import JSci.maths.SpecialMath; 4 5 10 public final class ChiSqrDistribution extends ProbabilityDistribution { 11 private double r; 12 private GammaDistribution gamma; 14 15 19 public ChiSqrDistribution(double dgr) { 20 if(dgr<=0.0) 21 throw new OutOfRangeException("The degrees of freedom must be greater than zero."); 22 r=dgr; 23 gamma=new GammaDistribution(0.5*r); 24 } 25 28 public double getDegreesOfFreedom() { 29 return r; 30 } 31 35 public double probability(double X) { 36 return 0.5*gamma.probability(0.5*X); 37 } 38 42 public double cumulative(double X) { 43 checkRange(X,0.0,Double.MAX_VALUE); 44 return SpecialMath.incompleteGamma(0.5*r,0.5*X); 45 } 46 50 public double inverse(double probability) { 51 if(probability==1.0) 52 return Double.MAX_VALUE; 53 else 54 return 2.0*gamma.inverse(probability); 55 } 56 } 57 58 | Popular Tags |