1 package JSci.maths.statistics; 2 3 8 public final class ParetoDistribution extends ProbabilityDistribution { 9 private double shape; 10 private double scale; 11 12 17 public ParetoDistribution(double sh,double sc) { 18 if(sh<0.0) 19 throw new OutOfRangeException("The shape parameter should be positive."); 20 shape=sh; 21 if(sc<0.0) 22 throw new OutOfRangeException("The scale paremeter should be positive."); 23 scale=sc; 24 } 25 28 public double getShapeParameter() { 29 return shape; 30 } 31 34 public double getScaleParameter() { 35 return scale; 36 } 37 40 public double getMean() { 41 return shape*scale/(shape-1.0); 42 } 43 46 public double getVariance() { 47 return shape*scale*scale/((shape-2.0)*(shape-1.0)*(shape-1.0)); 48 } 49 54 public double probability(double X) { 55 if(X<scale) 56 throw new OutOfRangeException("X should be greater than or equal to the scale."); 57 return shape*Math.pow(scale/X,shape)/X; 58 } 59 63 public double cumulative(double X) { 64 if(X<scale) 65 throw new OutOfRangeException("X should be greater than or equal to the scale."); 66 return 1.0-Math.pow(scale/X,shape); 67 } 68 72 public double inverse(double probability) { 73 checkRange(probability); 74 return scale/Math.pow(1.0-probability,1.0/shape); 75 } 76 } 77 78
| Popular Tags
|