Ok here's the deal, I have been working on code to do this but it doesn't seem right, 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)
here's the program:
// Example program
#include <iostream>
#include <string>
using namespace std;
int maxNum = 100;
int main()
{
for(float i = 0; i <= maxNum; i += 10)
{
float change = i / ((float)maxNum) / 2.0;
cout << (int)i << " / " << maxNum << " = " << change << " " << ( int(100 * change)) << "% " << endl;
}
}
Which outputs:
0 / 100 = 0 0%
10 / 100 = 0.05 5%
20 / 100 = 0.1 10%
30 / 100 = 0.15 15%
40 / 100 = 0.2 20%
50 / 100 = 0.25 25%
60 / 100 = 0.3 30%
70 / 100 = 0.35 35%
80 / 100 = 0.4 40%
90 / 100 = 0.45 45%
100 / 100 = 0.5 50%
where the final (100 / 100) seems to be correct result but the five first calculations doesn't seem right. 10 / 100 should be 10% but I'm not sure if I got that part right.
any ideas how to make this work?