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