Make Your Own Binomial Machine

Posted on May 2, 2012


Here’s how to make a Fathom simulation that will let you change the parameters of a binomial distribution quickly. Note that this may not be best for instruction.

  1. In a new document, make two new sliders, N and p.
  2. Make a table and give it 1000 cases.
  3. Make one attribute (call it successes or anything you like).
  4. Give it this formula: randomBinomial( N, p ). You will see domain errors. That’s because p is probably still 5. We’ll fix that shortly.
  5. (And now the sneaky bits) Double-click the N slider to bring up its inspector.
  6. Beside “Restrict_to_multiples_of” enter 1. After all, you can’t flip a coin 7.5 times.
  7. We've just told this slider to be integer-only.

  8. Now double-click the p slider to get its inspector, and change its bounds to extend from 0 to 1. After all, it’s a probability.
  9. Now use the sliders and see the distribution change.

To Improve

The randomBinomial( N, p ) function gives a number of successes for N independent trials, each with probability p of success. So if you change N dramatically, you may have to rescale the graph a lot (depending on what you’re trying to show).

So make a new attribute you might call pHat, with this formula:

randomBinomial( N, p ) / N

Now you can plot pHat, and as you change N and P, the graph will stay within reasonable bounds.

For a good time, set N = 20 and plot pHat as a histogram. Then press the animation button on the p slider…