A question about Pseudo-random number generator

Discuss the language of the universe.

Moderators: kiore, Blip, The_Metatron

Re: A question about Pseudo-random number generator

#21  Postby The_Metatron » Apr 18, 2022 3:29 pm

I can’t figure out why you aren’t simply treating the output you want like a bucket. A bucket in the shape of zero point shitloads_of_random_numbers.

“0.<AS_MANY_BITS_OF_RANDOM_NUMBERS_HERE_AS_YOU_LIKE>”.

Fill the bucket, use it as your desired number between zero and one. You have the hardware RNG to give you all the random numbers you want to fill that bucket.

Why are you bothering to sign it, get its absolute value then invert it?
User avatar
The_Metatron
Moderator
 
Name: Jesse
Posts: 22534
Age: 61
Male

Country: United States
United States (us)
Print view this post

Re: A question about Pseudo-random number generator

#22  Postby scott1328 » Apr 18, 2022 4:33 pm

The_Metatron wrote:I can’t figure out why you aren’t simply treating the output you want like a bucket. A bucket in the shape of zero point shitloads_of_random_numbers.

“0.<AS_MANY_BITS_OF_RANDOM_NUMBERS_HERE_AS_YOU_LIKE>”.

Fill the bucket, use it as your desired number between zero and one. You have the hardware RNG to give you all the random numbers you want to fill that bucket.

Why are you bothering to sign it, get its absolute value then invert it?

As I said to Thommo:
scott1328 wrote:

I know it seems stupid, but this function "RANDOM()" is intended to be a drop-in replacement for the builtin random function that is a really poor PRN. It returns a double (64 bit floating point number with a 53 bit mantissa) in the range between 0 and 1.

Most of the applications that make use of this function convert the return value back to a signed four byte integer.

The remainder of the applications only consider the first 2 decimal digits of the return value.

I think the implementation we have is good enough. To avert the overflow error, all that is needed is to flip the most significant bit to 0 instead of using the Absolute value function. Presuming this doesn't break the randomness in any significant way.
User avatar
scott1328
THREAD STARTER
 
Name: Some call me... Tim
Posts: 8849
Male

United States (us)
Print view this post

Previous

Return to Mathematics

Who is online

Users viewing this topic: No registered users and 1 guest