samedi 30 mai 2015

Create a Random Number Generator method from A given Random number generator method with different range

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).

  1. but will the equal probability property be maintained.
  2. Also what about the case when (k<n)

`




Aucun commentaire:

Enregistrer un commentaire