Geometric distribution Fitbit app bug

Recently, I found myself working on a Fitbit app for someone (https://github.com/indieda/AngadCapstone.git). It’s basically an app that can track exercise sessions and do certain actions during the exercise routine itself.

I ran into this problem where I would generate a random time between 0-300 seconds, and check when my running timer was more than that random number, to trigger an action. I found myself consistently getting actions being triggered in under a minute, and was hugely perplexed. I expected it to be triggered with a big spread, from 0-300 seconds. The problem can be summarized below:

What is the statistical distribution of time t, assuming we repeated this experiment a huge amount of times:

1) I’m checking for the first time that time (t in seconds) is more than variable x. 

2) variable x is a random number generated, that will be between 0 to 300 seconds

3) Every second, number x is randomly generated again

4) My program starts from 0s

Answer: This is the geometric distribution, the probability of hitting the first success on nth trial. (Credits once again to Arthur for pointing me back to my IB HL Math which I’d forgotten!)

That’s all for this post, hope this tickled your mind! Remember to exercise regularly. 😀

Leave a Reply