1 package JSci.maths.statistics; 2 3 import JSci.maths.SpecialMath; 4 5 10 public final class WeibullDistribution extends ProbabilityDistribution { 11 private double shape; 12 13 17 public WeibullDistribution(double sh) { 18 if(sh<=0.0) 19 throw new OutOfRangeException("The shape parameter should be positive."); 20 shape=sh; 21 } 22 25 public double getShapeParameter() { 26 return shape; 27 } 28 31 public double getMean() { 32 return SpecialMath.gamma(1.0+1.0/shape); 33 } 34 37 public double getVariance() { 38 return SpecialMath.gamma(1.0+2.0/shape)-getMean()*getMean(); 39 } 40 46 public double probability(double X) { 47 checkRange(X,0.0,Double.MAX_VALUE); 48 final double XpowShape=Math.pow(X,shape); 49 return shape*XpowShape/X*Math.exp(-XpowShape); 50 } 51 56 public double cumulative(double X) { 57 checkRange(X,0.0,Double.MAX_VALUE); 58 return 1.0-Math.exp(-Math.pow(X,shape)); 59 } 60 64 public double inverse(double probability) { 65 checkRange(probability); 66 return Math.pow(-Math.log(1.0-probability),1.0/shape); 67 } 68 } 69 70 | Popular Tags |