I know there are a few libraries offering functions to generate random distributions. Well, I want to write my own function, which
- creates a uniform distribution
- creates an exponential distribution
To do so, I have created a Linear Congruential Generator:
long Module::LCG()
{
RN = (16807*RN)%(2^31-1);
return RN;
}
And now, I don't know how to proceed. For a uniform distribution, I need to have both an interval in which the generated numbers lie, and a mean and a standard deviation:
long Module::createUniform(int min, int max)
{
for(int i=min; i<=max ;i++)
{
LCG(); //can I invoke LCG() here ?
}
}
And I'm missing out on the mean and standard deviation here, but don't know as on how to include them. Also, both createUniform and LCG() are public functions of the class Module. Can the function createUniform even invoke LCG()?
Aucun commentaire:
Enregistrer un commentaire