| 1 | package de.uka.ipd.sdq.probfunction.math.apache.distribution; |
| 2 | |
| 3 | import org.apache.commons.math.MathException; |
| 4 | import org.apache.commons.math.distribution.NormalDistribution; |
| 5 | import org.apache.commons.math.distribution.NormalDistributionImpl; |
| 6 | |
| 7 | public class LognormalDistributionImpl extends NormalDistributionImpl implements NormalDistribution |
| 8 | { |
| 9 | |
| 10 | // final double mu, sigma; |
| 11 | |
| 12 | /** Serializable version identifier */ |
| 13 | private static final long serialVersionUID = -4630735663414796584L; |
| 14 | |
| 15 | /** |
| 16 | * Create a normal distribution using the given mean and standard deviation. |
| 17 | * @param mean mean for this distribution |
| 18 | * @param sd standard deviation for this distribution |
| 19 | */ |
| 20 | public LognormalDistributionImpl(double mu, double sigma) |
| 21 | { |
| 22 | super(mu, sigma); |
| 23 | // this.mu = mu; |
| 24 | // this.sigma = sigma; |
| 25 | // |
| 26 | } |
| 27 | |
| 28 | @Override |
| 29 | public double cumulativeProbability(double x) throws MathException |
| 30 | { |
| 31 | if(x == 0) |
| 32 | return 0.0; |
| 33 | |
| 34 | return super.cumulativeProbability(Math.log(x)); |
| 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public double cumulativeProbability(double x0, double x1) throws MathException |
| 39 | { |
| 40 | return super.cumulativeProbability(Math.log(x0), Math.log(x1)); |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public double getMean() { |
| 45 | return super.getMean(); |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public double density(double x) |
| 50 | { |
| 51 | return super.density(Math.log(x))/x; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | @Override |
| 56 | public double getStandardDeviation() { |
| 57 | return super.getStandardDeviation(); |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public double inverseCumulativeProbability(double p) throws MathException { |
| 62 | return super.inverseCumulativeProbability(p); |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | protected double getInitialDomain(double p) { |
| 67 | // TODO Auto-generated method stub |
| 68 | return Math.exp(super.getInitialDomain(p)); |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | protected double getDomainLowerBound(double p) { |
| 73 | // TODO Auto-generated method stub |
| 74 | return Math.exp(super.getDomainLowerBound(p)); |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | protected double getDomainUpperBound(double p) { |
| 79 | // TODO Auto-generated method stub |
| 80 | return Math.exp(super.getDomainUpperBound(p)); |
| 81 | } |
| 82 | |
| 83 | |
| 84 | |
| 85 | } |