1. RE: 32-bit random numbers

The resulting distributions are good, but there is a problem.
As rand(power(2, 30) -1) can generate only 2^30 - 1 different numbers, no
matter what you do with these numbers, you will get possibly only 2^30 - 1
different numbers between 1 and 2^32, and so you will never get one of the
remaining 2^32 - 2^30 numbers, or 3/4ths of the total possibilities.
Regards.
----- Original Message -----
From: Juergen Luethje <j.lue at gmx.de>
To: <EUforum at topica.com>
Sent: Tuesday, July 06, 2004 7:47 PM
Subject: Re: 32-bit random numbers


>
>
> Hi Igor, you wrote:
>
> > Hi again Jurgen,
> >
> > Me wrote:
>
> <snip>
>
> >> Get one trick more:
> >>
> >> To get the 32 bit rnd flat distribution
> >> you can do the following steps:
> >>
> >> a. Get rnd number in [0,1] range from the EU standard rand()
> >> b. Get rnd number in needed range from [0,1] range.
> >>
> >> It may be done as:
> >>
> >> }}}
<eucode>
> >> atom k
> >> k = 1 / 1073741823 -- the biggest EU integer
> >> atom rnd_0_1
> >>
> >> function rand_0_N(atom N)
> >>   rnd_0_1 = k * (rand(1073741823)-1)
> >>   return floor(N * rnd_0_1)
> >> end function
> >>
> >> for i=1 to 1000 do
> >>     ? 1 + rand_0_N(#FFFFFFFF) -- this distribution
> >>                               -- is in [1,#FFFFFFFF] range
> >> end for
> >> </eucode>
{{{

>
> Cool! Why didn't I think of that? smile
>
> > Yes, it seems to be:
> >
> > for i=1 to 1000 do
> >     ? 1 + rand_0_N(#FFFFFFFF - 1)
> >  -- this distribution
> >  -- is in [1,#FFFFFFFF] range
> > end for   ----    blink
>
> It seems to me, that your *first* version was correct, wasn't it?
> For testing, I used N=6:
>
> }}}
<eucode>
> atom k
> k = 1 / 1073741823 -- the biggest EU integer
> atom rnd_0_1
>
> function rand_0_N(atom N)
>   rnd_0_1 = k * (rand(1073741823)-1)
>   return floor(N * rnd_0_1)
> end function
>
> atom N, x, min, max
>
> N = 6
> min = 1 + rand_0_N(N)
> max = min
> for i=1 to 1000 do
>    x = 1 + rand_0_N(N)  -- this distribution is in [1,6] range
>    if x < min then
>       min = x
>    elsif x > max then
>       max = x
>    end if
> end for
> printf(1, "range [%d,%d]", {min, max})
> </eucode>
{{{

>
> Thanks, Igor!
>
> Regards,
>    Juergen
>
>
>
>

new topic     » topic index » view message » categorize

2. RE: 32-bit random numbers

Hi, both Igor and Al.
Actually I didn't say anything about these formulas. In an older post, I was
referring to another formula saying not that it wasn't flat, but that it
didn't generate all possible numbers. It was flat, however.
Regarding Al's formula and Igor's formula, it seems to me they both produce
flat distributions, but this is only shallow thinking and I haven't yet
tried to prove their flatness.
Regards.
----- Original Message -----
From: Igor Kachan <kinz at peterlink.ru>
To: <EUforum at topica.com>
Sent: Sunday, July 11, 2004 4:01 AM
Subject: Re: 32-bit random numbers


>
>
> Hi Al,
>
> ----------
> > From: Al Getz <guest at RapidEuphoria.com>
> > To: EUforum at topica.com
> > Subject: Re: 32-bit random numbers
> > Sent: 10 jul 2004 y. 23:36
> >
> >
> > posted by: Al Getz <Xaxo at aol.com>
> >
> > Igor Kachan wrote:
> >
> >
> > >  I can say nothing about the distribution
> > >  on your formula. I just see it is not flat.
> >
> > Ok, it's one thing to *SAY* it's not flat,
> > for example, i can *SAY* YOURS isnt flat,
> > but it's another story to *PROVE* it's not flat.
> >
> > You see now?
>
> Yes, I see. It is not flat, your distribution.
> This my affirmation is very common.
> I can say nothing about concrete parameters of
> your distribution, it is the same thing that
> I can say nothing about the distribution on
> your formula, yes.
>
> Formula is yours, try to prove it is good.
> This is not my problem, Al.
>
> I am trying to explain that N must be <<< K
> in proposed the rand_atom() function.
>
> Did you understand my explanation?
>
> > You can teach a 4 year old to say
> > 'everything is not flat' but it's not true,
> > is it?
>
> He he, Al, even an any 40 years old can not
> understand the Einstein's theory about
> all curved spaces  blink
>
> > In other words, PROVE it's not flat.
>
> Al, distribution is yours, we need the flat one,
> prove please yours one is flat.
>
> BTW, it is the very complicated task
> to create a good flat RNG, very, ask Rob.
>
> rand() is one of the good examples.
> We use it for our tasks.
>
> > The reason i say this is because it looks like the
> > distribution *IS* flat, but there is of course always
> > the chance i made a mistake in the analysis, im just
> > human!
>
> I'm just human too, it seems to be, no?  blink
>
> > So, if you want me to understand why you say
> > it is *NOT* flat, please show me how you came
> > to this conclusion.
>
> Al, it is very long another [OT] story, I worked
> on Russian navy research many years, models-shmodels,
> we used Monte Carlo method, these RNGs-sh-sh-mrngs ...
> brrrr ...
>
> Another story, Al, books-sh-m-books ...
>
> Ricardo knows, he says too - not flat.
>
> Believe him.
>
> > BTW, i wasnt saying YOUR function isnt flat,
> > im just asking why you needed another function,
> > that's all, and what the benefits are.
>
> We just need a flat discrete distribution in maximum
> integer range with step = 1.
> My function seems to give just this one.
> No another needs.
>
> > I thought maybe you wanted higher and higher
> > random integers so i proposed another solution smile
> > The proposed solution goes up to ANY desired integer
> > ceiling, not just #FFFFFFFF or whatever.
> > Im not saying there is no chance i made a mistake,
> > im just asking that you show me why you say
> > it's not flat, especially the
> >
> > N*(rand(N)-1)+rand(N)-1, with N=#10000
> >
> > formula?
<snip>

>
>
>

new topic     » goto parent     » topic index » view message » categorize

3. RE: 32-bit random numbers

Hi there Ricardo,

Oh ok, thanks for clearing that up.
I did quite a few tests on mine before i posted it just
to make sure it was flat.  Then Igor for some reason said
it wasnt flat and wouldnt tell me why he thought that, so 
i said his was flat just so he would know what it's like 
when someone says yours isnt flat and doesnt give a 
reason smile

These prng's are pretty interesting.

Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu