25package umontreal.ssj.randvar;
27import umontreal.ssj.probdist.DiscreteDistribution;
28import umontreal.ssj.rng.RandomStream;
29import umontreal.ssj.probdist.Distribution;
86 throw new IllegalArgumentException(
"The arrays dists and weigths must have the same length");
91 initWeightDistribution();
98 private void initWeightDistribution() {
99 int[] idx =
new int[
weights.length];
100 for (
int i = 0; i < idx.length; i++)
117 throw new UnsupportedOperationException(
"Use getDistributions method instead");
142 int idx = (int) Math.round(
weightsDist.inverseF(stream.nextDouble()));
145 return dists[idx].inverseF(stream.nextDouble());
This class implements discrete distributions over a finite set of real numbers (also over integers as...
Distribution[] getDistributions()
Returns the distributions of this mixture.
DiscreteDistribution weightsDist
The discrete distribution that is used to select randomly a distribution from the mixture when genera...
double nextDouble()
Generates a random number from the continuous distribution contained in this object.
MixtureGen(RandomStream s, Distribution[] dists, double[] weights)
Creates a new mixture distribution generator defined by the given.
double[] getWeights()
Returns the probability associated with each distribution of the mixture.
double[] weights
The probability of each distribution that compose this mixture, see variable dists .
Distribution getDistribution()
This method is not supported, it will throw an UnsupportedOperationException.
Distribution[] dists
The different distributions that compose this mixture.
This interface should be implemented by all classes supporting discrete and continuous distributions.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...