Help with Random Seed

Hello :wave:
So I’m trying to make a randomized percentage based randomization function
and It’s somewhat accurate however it tends to fluctuate weirdly, I want it to be as correct as possible.

Example:
image
it should be like this

Legendary = 10
Rare = 20
Uncommon = 30
Common = 40

And I think in order to do that the only solution would be to use a seed.
Since I’ve used Random.new(40)

and this happened:
image

However I’m very confused on how to make it work with various results.
Now I have tried looking into this various times and even went to different forums on other programming languages on how to make seeds work with lots of results, and I still don’t understand how it can work in away that it makes one number more common then another and the other one more common, etc.

I’d really appreciate if anyone has some tips I could use on this subject and thank you so much for reading thus far! :smiley:

What you’re experiencing is experimental probability. What you’re expecting is the theoretical probability.

If you run enough test cases your experimental probability will always lean closer and closer towards that theoretical, but will never reach it.

It wouldn’t be random anymore if you required it to fit the theoretical probability at all times.

Think of it like flipping a coin. You can flip heads more than once in a row.

1 Like

Try running a simulation over a 1000 times then average the result for each rarity.

If done correctly, the values for each rarity should start nearing the value you want for each.

image
I’d say this is slightly more accurate :smiley:

1 Like