1 package JSci.maths.statistics; 2 3 8 public final class CauchyDistribution extends ProbabilityDistribution { 9 private double alpha; 10 private double gamma; 11 12 15 public CauchyDistribution() { 16 this(0.0,1.0); 17 } 18 23 public CauchyDistribution(double location,double scale) { 24 if(scale<0.0) 25 throw new OutOfRangeException("The scale parameter should be positive."); 26 alpha=location; 27 gamma=scale; 28 } 29 32 public double getLocationParameter() { 33 return alpha; 34 } 35 38 public double getScaleParameter() { 39 return gamma; 40 } 41 46 public double probability(double X) { 47 final double y=X-alpha; 48 return gamma/(Math.PI*(gamma*gamma+y*y)); 49 } 50 54 public double cumulative(double X) { 55 return 0.5+Math.atan((X-alpha)/gamma)/Math.PI; 56 } 57 61 public double inverse(double probability) { 62 checkRange(probability); 63 return alpha-gamma/Math.tan(Math.PI*probability); 64 } 65 } 66 67 | Popular Tags |