On Wednesday, November 27, 2019 22:31 CET, Fran=C3=A7ois Po= ttier <francois.pottier@inria.fr> wrote:

Hello,

I am using zarith and would like to pick a random = integer
comprised between 0 and some bound. I would like a functio= n
Z.random of type Z.t -> Z.t, but this function seems to bemissing, and I am not sure how to program it in an efficient
an= d correct way. Any suggestions would be welcome. Thanks!

&nb= sp;

I tend to believe that the following idea might b= e good, but please check with real probability experts. I definitely am= not one (but one of my best colleagues is one).

Let B be th= e bound.

You take a random number modulus 2*B. Let R be that= number

You modelize the [0;B[ interval as a ring of numbers= . For example if B is 5 : 0 -> 1 -> 2 -> 3 -> 4 -> 0 -&g= t; 1 -> .... ad infinitium

You memoize the previous= ly given random number N

On that ring, you go R steps forwar= d and obtain P. That is your new random number and on the next iteratio= n the R would be that P

But check with an expert, I am not o= ne

--

Basile
------=_=-_OpenGroupware_org_NGMime-23791-1574933237.884173-22--------