| 1 | package de.uka.ipd.sdq.simucomframework.variables.functions; |
| 2 | |
| 3 | import java.util.List; |
| 4 | |
| 5 | import de.uka.ipd.sdq.probfunction.math.IBinomialDistribution; |
| 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 BinomFunction extends AbstractProbDistFunction { |
| 12 | |
| 13 | |
| 14 | |
| 15 | public BinomFunction(IRandomGenerator randomGen, IPDFFactory factory) { |
| 16 | super(randomGen, factory); |
| 17 | |
| 18 | } |
| 19 | |
| 20 | public boolean checkParameters(List<Object> parameters) { |
| 21 | if (parameters.size() == 2 && |
| 22 | (parameters.get(0) instanceof Integer) && |
| 23 | (parameters.get(1) instanceof Double)) |
| 24 | { |
| 25 | return true;} |
| 26 | else |
| 27 | { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | } |
| 32 | |
| 33 | public Object evaluate(List<Object> parameters) { |
| 34 | int n = (Integer) parameters.get(0); |
| 35 | double p = NumberConverter.toDouble(parameters.get(1)); |
| 36 | IBinomialDistribution distribution = factory.createBinomialDistribution(n, p); |
| 37 | return distribution.inverseF(randomGen.random()); |
| 38 | |
| 39 | } |
| 40 | |
| 41 | } |