How to make a value scale with a probability?

261 Views Asked by At

Say I have a 50/50 chance to win/lose, and I have another value which is strength which starts at 0 but rises up by 5 every win to a max of 95. And every 5 strength ups my odds to win up to 95/100. I know this is simple arithmetic but, for some reason I can't get an idea how to start it. I am basically just looking for the general formula or logic for this type of scaling

2

There are 2 best solutions below

3
On BEST ANSWER

It sounds like you're looking for something like this: $$P(s) = \frac{50+\frac{45}{95}s}{100}$$ where $s$ is your strength and $P$ is the chance of winning. When $s=0$, the odds are 50-50, and as $s$ increases, so does $P$, up to $P(95) = 0.95$.


EDIT: I updated the formula to work for a maximum strength of $95$ instead of $45$. The formula can be simplified (starting by reducing $\frac{45}{95}$ to $\frac{9}{19}$), but I left it as written to show the relationship to $95$.

0
On

Sounds like you want a simple computer program. Here is a JavaScript version of something similar.

    chanceToWin=0.5;
    strength=0;
    win=0;
    count=0;
    while (win<10) {
      count++;
      if (Math.random()<chanceToWin+strength) {
        win++;
        strength+=0.05;
        if (strength>0.45) strength=0.45;
      }
    }
    alert('You won 10 times in : '+count+' goes.');

Math.random() returns a random number from $[0,1)$.