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