package umontreal.iro.lecuyer.randvarmulti;
import umontreal.iro.lecuyer.randvar.RandomVariateGen;
/**
* Extends {@link RandomMultivariateGen} for a vector of independent identically distributed
* (i.i.d.) random variables.
*
*/
public class IIDMultivariateGen extends RandomMultivariateGen {
/**
* Constructs a generator for a d-dimensional vector of i.i.d. variates
* with a common one-dimensional generator gen1.
*
* @param gen1 the one-dimensional generator
*
* @param d dimension of the vector (number of i.i.d. variates).
*
*/
public IIDMultivariateGen (RandomVariateGen gen1, int d) {
setGen1 (gen1);
this.stream = gen1.getStream();
dimension = d;
}
/**
* Changes the dimension of the vector to d.
*
*/
public void setDimension (int d) {
dimension = d;
}
/**
* Generates a vector of i.i.d. variates.
*
*/
public void nextPoint (double[] p) {
if (p.length != dimension)
throw new IllegalArgumentException(String.format(
"p's dimension (%d) does not mach dimension (%d)", p.length, dimension));
for (int i = 0; i < dimension; i++)
p[i] = gen1.nextDouble();
}
/**
* Sets the common one-dimensional generator to gen1.
*
*/
public void setGen1 (RandomVariateGen gen1) {
if (gen1 == null)
throw new NullPointerException ("gen1 is null");
this.gen1 = gen1;
}
/**
* Returns the common one-dimensional generator used in this class.
*
*/
public RandomVariateGen getGen1() {
return gen1;
}
/**
* Returns a string representation of the generator.
*
*/
public String toString() {
return dimension + "-dimensional vector of i.i.d. " +
gen1.getDistribution().toString();
}
}
Ads help maintain this website.