Re: random_number
- From: "robin" <robin_v@xxxxxxxxxxx>
- Date: Mon, 21 Nov 2005 13:58:00 GMT
James Giles wrote in message ...
>robin wrote:
>...
>> There's nothing "fundamentally flawed" about the method,
>> as the following proves. Below are printed the first ten values
>> below 1.0 (left-hand column) and their products (right-hand column)
>> with
>> the nearest value above 1.0 :- Only the least-significant 8 bits of
>> each mantissa are printed.
>>
>> 11111111 00000000
>> 11111110 11111111
>> 11111101 11111110
>> 11111100 11111101
>> 11111011 11111100
>> 11111010 11111011
>> 11111001 11111010
>> 11111000 11111001
>> 11110111 11111000
>
>Most random number generators return values in the
>interval 0 <= r < 1 that are uniformly spaced in that
>interval and are equiprobable.
Ideally, yes, but in practice, they are pseudo (note, pseudo)
and aren't perfect.
> Both of those last properties
>are very desirable. Your "solution"
It was a suggestion. Please note the wording:
"You could try multiplying your random number by
"NEAREST(1.0, 2.0)
"and, just for safety, checking that the product is
"not greater than 1.0. If it is, replace it with 1.0."
There are many options available to the OP, including
adapting and/or using one of the numerous PNRGs
available in computer science literature and on the internet.
> will not return values
>on the interval 0 <= r <= 1 that are uniformly spaced.
I am sure that everyone is aware of that. However,
virtually all are [uniformly spaced].
>For example, on IEEE single precision, you get 2^24
>values in the interval 0 <= r < 1 and the spacing between
>the possible results is 1/2^24.
Do you really think that anyone might notice the one in
some 16,000,000?
In a typical use, the value might never be generated anyway.
BTW, I have been writing pseudo-random number
generators and using PRNGs for 30+ years, so the
remainder is
<snipped>
>--
>J. Giles
.
- Follow-Ups:
- Re: random_number
- From: Rich Townsend
- Re: random_number
- References:
- Re: random_number
- From: robin
- Re: random_number
- From: Rich Townsend
- Re: random_number
- From: robin
- Re: random_number
- From: James Giles
- Re: random_number
- Prev by Date: Re: Important: is Alpha
- Next by Date: Re: LAPACK & Intel 9.0: unexpected behaviour (bug?)
- Previous by thread: Re: random_number
- Next by thread: Re: random_number
- Index(es):
Relevant Pages
|