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.

- In a new document, make two new sliders,
**N**and**p**. - Make a table and give it 1000 cases.
- Make one attribute (call it
**successes**or anything you like). - 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. - (And now the sneaky bits) Double-click the
**N**slider to bring up its inspector. - Beside “
**Restrict_to_multiples_of**” enter**1**. After all, you can’t flip a coin 7.5 times. - 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. - 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…

Advertisements

Posted in:

*How-to, random-number functions*
Posted on May 2, 20120