Categories
Math Software

A Probability Surprise

For quite a while now I’ve been exercising on a regular basis. My favourite physiotherapist recently told me there was a fair bit of overlap in the exercises I was doing. I had multiple exercises that were working the same muscles. In these cases he suggested I could either just pick one of the two, or alternate between them.

I’m slightly embarrassed to admit that I get a bit excited when I stumble across a real life situation that gives me the (contrived?) opportunity to tell myself “I can build an app for that!”

Specifically, I started out wanting to build an app that would:

  1. have the details of all the exercises I use
  2. know which ones could be alternated
  3. generate a ‘random’ program that would select among the pairs of exercises that were interchangeable.

But then I thought of a couple of things that caused me to increase the scope of the project.

  1. I wanted to be able to specify the relative probabilities in a pair of exercises (for example pick one 65% of the time and pick the other 35% of the time)
  2. I wanted to be able to choose 2 exercises out of a group of 4 and have it randomly pick different pairs.

For example, I have 4 calf exercises, and I wanted to randomly pick 2 each time I was working out. So if I weighted all 4 equally and picked 2 each one would be included 50% of the time. But if I weight one at 50% and the other 3 at 16.67%, when I choose 2, how frequently would the 50% exercise be selected?

SideNote: Why does it matter what fraction of the time an exercise gets picked? In terms of building the app, it doesn’t really matter. My main motivation for figuring out how to calculate this was to make sure that the random selection code was working correctly.

In the case where the app picks 2 items from a set of four individually weighted choices, how could I determine how frequently each item would get picked.

  1. list all the possible combinations [(1,2), (1,3), (1,4), (2,1), (2,3), (2 ,4), (3,1), (3,2), (3 ,4), (4,1), (4,2), (4,3)]
  2. determine the probability of each combination. Note that the probability calculations for the second selection need to exclude the item that was picked first. For example, using the previous values (50%, 16.67%, 16.67%, 16.67%) when 1 is picked first, the probabilities for 2,3,4 will all be 33%. When 2 is picked first, the probabilities for 1,3,4 will be 60%, 20%, 20%
  3. for each combination in step 1, multiply the probabilities for the first pick and the second pick, to determine the probability of each combination. Note in the current example
    (1,2) => (50% x 33.33%) => 16.67% but
    (2,1) => (16.67% x 60%) => 10%
  4. make sure the sum of all the probabilities is 100%
  5. sum the probabilities for all the combinations that include the item in question. For example, item 2’s list of combinations would be [(1,2), (2,1), (2,3), (2 ,4), (3,2), (4,2)]

But here’s the part that was counterintuitive (at least to me): When I change the relative weighting of item 1 and item 2, the probailities for item 3 and item 4 will change. (even though their weightings stay exactly the same.

In the 4 choose 2 example, when all 4 items are weighted equally, all items will appear in 50% of the results. But when item 1 is reduced to 5% and item 2 is increased to 45% (items 3 and 4 are both left at 25%) item 3 and item 4 will now appear in 55% of results.

Leave a Reply

Your email address will not be published. Required fields are marked *