1 | package de.uka.ipd.sdq.simucomframework.variables.functions; |
2 | |
3 | import java.util.List; |
4 | |
5 | import de.uka.ipd.sdq.probfunction.math.IExponentialDistribution; |
6 | import de.uka.ipd.sdq.probfunction.math.IPDFFactory; |
7 | import de.uka.ipd.sdq.probfunction.math.IRandomGenerator; |
8 | |
9 | import de.uka.ipd.sdq.simucomframework.variables.converter.NumberConverter; |
10 | |
11 | public class ExpDistFunction extends AbstractProbDistFunction { |
12 | |
13 | |
14 | public ExpDistFunction(IRandomGenerator stream, IPDFFactory factory) { |
15 | super(stream, 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 lambda = NumberConverter.toDouble(parameters.get(0)); |
28 | IExponentialDistribution distribution = factory.createExponentialDistribution(lambda); |
29 | return distribution.inverseF(randomGen.random()); |
30 | } |
31 | |
32 | } |