|
In
my example there is an enumeration type that defines four operations. Now each
enumeration value is associated with a number, starting from 0. So in the case
of these commands we would have a number range from 0 to 3, and we only can
generate numbers in this range with equal probability.
typedef enum
{ nop, reset, load, count} command_t;
How
to write a function that can count the percentage of the occurrence of each of
the numbers which could be used to generate a weight?
If
the $urandom_range() function returns a number that has already occurred
according to the weight then you just discard it, how to call that function
again and use the new (most likely different) number? Thanks, Mihaela
|