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.IRandomGenerator; |
7 | |
8 | import de.uka.ipd.sdq.probfunction.math.IUniformIntDistribution; |
9 | |
10 | |
11 | |
12 | public class UniIntDistFunction extends AbstractProbDistFunction { |
13 | |
14 | |
15 | public UniIntDistFunction(IRandomGenerator random, IPDFFactory factory) { |
16 | super(random, factory); |
17 | } |
18 | |
19 | public boolean checkParameters(List<Object> parameters) { |
20 | if (parameters.size() != 2) |
21 | return false; |
22 | if (!(parameters.get(0) instanceof Integer && parameters.get(1) instanceof Integer)) |
23 | return false; |
24 | return true; |
25 | } |
26 | |
27 | public Object evaluate(List<Object> parameters) { |
28 | int a = (Integer) parameters.get(0); |
29 | int b = (Integer) parameters.get(1); |
30 | IUniformIntDistribution distribution = factory.createUniformIntDistribution(a, b); |
31 | return distribution.inverseF(randomGen.random()); |
32 | } |
33 | |
34 | } |