| 1 | /** |
| 2 | * |
| 3 | */ |
| 4 | package de.uka.ipd.sdq.probfunction.math.apache.impl; |
| 5 | |
| 6 | |
| 7 | import org.apache.commons.math.distribution.PoissonDistributionImpl; |
| 8 | |
| 9 | |
| 10 | import de.uka.ipd.sdq.probfunction.math.IPoissonDistribution; |
| 11 | import de.uka.ipd.sdq.probfunction.math.exception.DomainNotNumbersException; |
| 12 | import de.uka.ipd.sdq.probfunction.math.exception.FunctionNotInTimeDomainException; |
| 13 | |
| 14 | import de.uka.ipd.sdq.probfunction.math.exception.UnorderedDomainException; |
| 15 | |
| 16 | /** |
| 17 | * @author joerg |
| 18 | * |
| 19 | */ |
| 20 | public class PoissonDistribution extends AbstractDiscretePDF implements IPoissonDistribution{ |
| 21 | |
| 22 | public PoissonDistribution(double lambda) |
| 23 | { |
| 24 | this.internalFunction = new PoissonDistributionImpl(lambda); |
| 25 | } |
| 26 | |
| 27 | /* (non-Javadoc) |
| 28 | * @see de.uka.ipd.sdq.probfunction.math.IContinousPDF#getStandardDeviation() |
| 29 | */ |
| 30 | @Override |
| 31 | public double getStandardDeviation() |
| 32 | { |
| 33 | |
| 34 | double lambda = ((PoissonDistributionImpl)internalFunction).getMean(); |
| 35 | return Math.sqrt(lambda); |
| 36 | } |
| 37 | |
| 38 | /* (non-Javadoc) |
| 39 | * @see de.uka.ipd.sdq.probfunction.math.IContinousPDF#getXinf() |
| 40 | */ |
| 41 | @Override |
| 42 | public double getXinf() { |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | /* (non-Javadoc) |
| 47 | * @see de.uka.ipd.sdq.probfunction.math.IContinousPDF#getXsup() |
| 48 | */ |
| 49 | @Override |
| 50 | public double getXsup() { |
| 51 | |
| 52 | return Double.POSITIVE_INFINITY; |
| 53 | } |
| 54 | |
| 55 | |
| 56 | /* (non-Javadoc) |
| 57 | * @see de.uka.ipd.sdq.probfunction.math.IProbabilityFunction#getArithmeticMeanValue() |
| 58 | */ |
| 59 | @Override |
| 60 | public double getArithmeticMeanValue() throws DomainNotNumbersException, |
| 61 | FunctionNotInTimeDomainException { |
| 62 | return getMean(); |
| 63 | } |
| 64 | |
| 65 | /* (non-Javadoc) |
| 66 | * @see de.uka.ipd.sdq.probfunction.math.IProbabilityFunction#getMedian() |
| 67 | */ |
| 68 | @Override |
| 69 | public Object getMedian() throws UnorderedDomainException { |
| 70 | throw new UnsupportedOperationException(); |
| 71 | } |
| 72 | |
| 73 | /* (non-Javadoc) |
| 74 | * @see de.uka.ipd.sdq.probfunction.math.IProbabilityFunction#getPercentile(int) |
| 75 | */ |
| 76 | @Override |
| 77 | public Object getPercentile(int p) throws IndexOutOfBoundsException, |
| 78 | UnorderedDomainException { |
| 79 | throw new UnsupportedOperationException(); |
| 80 | } |
| 81 | |
| 82 | /* (non-Javadoc) |
| 83 | * @see de.uka.ipd.sdq.probfunction.math.IProbabilityFunction#hasOrderedDomain() |
| 84 | */ |
| 85 | @Override |
| 86 | public boolean hasOrderedDomain() { |
| 87 | throw new UnsupportedOperationException(); |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public double getLowerDomainBorder() { |
| 92 | throw new UnsupportedOperationException(); |
| 93 | } |
| 94 | |
| 95 | |
| 96 | |
| 97 | @Override |
| 98 | public double getMean() { |
| 99 | return ((PoissonDistributionImpl)internalFunction).getMean(); |
| 100 | } |
| 101 | |
| 102 | } |