Author Topic: my first RNG  (Read 260 times)

0 Members and 1 Guest are viewing this topic.

heatmap

my first RNG
« on: May 01, 2019, 07:32:32 PM »
I needed a random number generator and quick

didnt have time to google anything

so i coded this one...

its for an american wheel but if you change the $max number to 37 it should be fine

$min = 1; // this number is the lowest to choose from
$max = 38; // this number is the highest to choose from
$amount = 100; // the amount of numbers i am generating

while ($amount>0) {
        // this is what generates the random number
   $history[] = random_int ($min,$max);
   $amount--;
}

What is interesting is that for every 100 numbers i generate there are always 2 or 3 that never get generated out of the possible 38 numbers
 
The following users thanked this post: Third, UnlikelySam

Third

Re: my first RNG
« Reply #1 on: May 01, 2019, 07:56:45 PM »
Do you know the details of how your RNG is seeded?
 
The following users thanked this post: heatmap, UnlikelySam

heatmap

Re: my first RNG
« Reply #2 on: May 01, 2019, 09:26:17 PM »
Do you know the details of how your RNG is seeded?

This is the entire thing, so there is no seeding involved right now, but i think since I am running a windows environment so whatever is running within PHP and whatever PHP connects to in order to generate the random numbers MAY have its own seeding mechaninsm.

Seeding from what i understand will allow me to control the amount of different outcomes that are possible, so in the future that will be a part of this.

But this was simply to generate any amount of numbers for myself because I am currently moving an application and dont have it connected to a database and seeding was not really worth it for this instance.

I should be seeding though you are correct.
 
The following users thanked this post: Third, UnlikelySam

Third

Re: my first RNG
« Reply #3 on: May 01, 2019, 10:05:27 PM »
Well of course an unseeded TRNG is best but the modern seeding methods are pretty stunning! :D
 
The following users thanked this post: UnlikelySam