10 minutes ago, heh65532 said:
I'm unsure if I got the math right.
I made sample program where there's no arrays but I'm trying to calculate the probability for each number. 100 / 100 for example should have 50% probability.
Or in another example max number being 100 the number 10 should have 10% change of being picked.
(max number just means the highest number found in array)
It's hard to see how these 2 examples represent the same mathematics.
In the first example, it's 50/50 because each number is equal. Another way to view it is that the total weighting of the numbers is 200, and each of those numbers is 100, so each has a 100/200 chance, i.e. 0.5, which equals 50%.
In the second example, we know there is a number 100, and a number 10 - but that's a total weight of at least 110. If those are the only 2 numbers, then you'd expect the 10 to be picked 9% of the time (i.e. 10/110). If there were a few other numbers, that proportion could go down.
So I think you need to come up with a more rigorous definition of your weighting formula.