1 | package de.uka.ipd.sdq.simucomframework.variables.functions; |
2 | |
3 | import java.util.List; |
4 | |
5 | import de.uka.ipd.sdq.probfunction.math.IPDFFactory; |
6 | import de.uka.ipd.sdq.probfunction.math.IPoissonDistribution; |
7 | import de.uka.ipd.sdq.probfunction.math.IRandomGenerator; |
8 | import de.uka.ipd.sdq.simucomframework.variables.converter.NumberConverter; |
9 | |
10 | public class PoissonDistFunction extends AbstractProbDistFunction { |
11 | |
12 | |
13 | |
14 | public PoissonDistFunction(IRandomGenerator random, IPDFFactory factory) { |
15 | super(random, factory); |
16 | } |
17 | |
18 | public boolean checkParameters(List<Object> parameters) { |
19 | if (parameters.size() != 1) |
20 | return false; |
21 | if (NumberConverter.toDouble(parameters.get(0)) < 0) |
22 | return false; |
23 | return true; |
24 | } |
25 | |
26 | public Object evaluate(List<Object> parameters) { |
27 | double mean = NumberConverter.toDouble(parameters.get(0)); |
28 | IPoissonDistribution distribution = factory.createPoissonDistribution(mean); |
29 | return distribution.inverseF(randomGen.random()); |
30 | } |
31 | |
32 | } |