Random VariatesThe data type random_variate is a random number generator that generates ints according to an arbitrary static weight function.The generation process is governed by an Remark: The data type Random Variate can only generate ints. ExampleThe following program shows how to use random_variate.
#include <LEDA/core/random_variate.h>
#include <LEDA/core/array.h>
int main()
{
leda::array<int> w(3); //weight function
w[0]=1;w[1]=2;w[2]=3;
leda::random_variate R(w); //random_variate
int i=R.generate(); //random number
std::cout << i << std::endl;
return 0;
}
The program generates a very simple weight function |
See also:Dynamic Random Variates: a non-uniform random number generator with dynamic weight function Random Sources: a uniform random number generator |