I want to make a Random number generator using a given random number generator method.
Given a function f() that return a random number from 1 to k, create a function fn() that return a random number from 1 to n with equal probability.
where k can be be both less than or more than n (k<n or k>n).
I understand if (k > n) we can keep calling f() till it return (value <= n).
- but will the
equal probabilityproperty be maintained. - Also what about the case when
(k<n)
`
Aucun commentaire:
Enregistrer un commentaire