Program:	PROBLITY
Author:		Rob Gaebler
Date:		1/16/02

PROBLITY is a program that solves several types of discrete probability
problems.  When you run the program, you are given 7 options.  Each option
describes a particular kind of problem in a way that's easy to visualize.  Many
probability problems can be solved using one of these operations, it just may
take some thinking on your part to realize how the problems are actually
equivalent.  You have the following functions to choose from:

1: Colored Balls
Imagine you have a large bag with balls of various colors.  You draw balls out
of the bag, one at a time (with or without replacement).  This program finds
the probability, given a total number of balls to draw, that the balls will
have certain colors.  Example:  Suppose the bag contains 2 blue, 1 red, and 5
green balls, and you draw out 3 balls.  You want to find the probability that 2
are green and 1 is red.  You would enter the list of colors in the bag as {2,
1, 5} and the list of chosen balls as {0, 1, 2}.  The probability of this event
is .146 with replacement and .179 without replacement.

Here's an example of another type of problem that you could solve with this
program:  Suppose you have a population with 10 engineers, 3 mathematicians,
and 3 physicists, and you randomly select a sample of size 3.  You want to find
the probability that one person from each occupation will be chosen.  Think of
the people as "balls" and the occupations as "colors."  Than you would enter
the overall list of "colors" as {10, 3, 3} and the chosen list as {1, 1, 1}.
You pick the people without replacement, so the answer is .161.

If you are clever, you can solve lots of problems with the Colored Balls
program.  Often you can break up a probability problem into the sum of simpler
problems, and solve each smaller problem with the program.  Suppose instead of
finding the probability that one person of each occupation is chosen as in the
example above, you want the probability that exactly one is a mathematician
(out of three people chosen).  This breaks down into three cases: 2E 1M 0P,
1E 1M 1P, and 0E 1M 2P.  You would then use the program to find the probabilty
of each of these events, and add the probabilities.

2: All Different
Suppose there is a set of objects to choose from, each with equal likelihood,
and you randomly pick from these objects with replacement, one at a time.  An
example of such a situation is rolling a standard 6-sided die.  The "objects"
are the numbers 1 to 6, and you roll the die a few times.  This program
computes the probability that all the outcomes are different from one another.
For example, if you roll a die 3 times, you would enter 6 as the "number of
choices" and 3 as the number of times to choose.  The probability that the
3 rolls are all different is .556 (or 5/9).

3: Total Probability P
Suppose a certain event has a certain probability R, and you want to do enough
trials so that the probability of the event happening at least once is exactly
P.  This program computes the number of trials you have to do.  The answer is
generally not an integer.  You must round up the answer if you want to make
sure the total probabilty is at least P.  Example: Toss a fair coin, so that
heads has a 1/2 probability of coming up.  How many times must you toss the
coin so that the probability of at least one head is 95%?  Enter .5 as the
Prob/Trial and .95 as the Combined Prob.  The answer is 4.32, so you would have
to flip the coin 5 times to have at least a 95% chance of getting a head.

4: M in N Tries
Computes the probability of getting M successes in N trials, given the
probability of a success in a single trial.  For example, suppose you want to
find the probability of getting at least one head if you flip a coin 5 times.
The probability per trial is 1/2, M is 1, and N is 5.  The probability is .969
(compare this answer with the one obtained with Total Probability P).  The
program computes the probability of getting at least M and getting exactly M
successes.

5: Poisoned Apple
Suppose there is a barrel with some good apples and some bad (poisoned) apples.
You start picking out apples one at a time.  This program calculates the
probability that no bad apples will be picked, given the total number of apples
picked, with replacement and without replacement.  It also displays a list for
both cases.  The elements in the list are the cumulative probability of picking
no bad apples (the last element in the list is the answer you want).  The list
is displayed as extra, possibly useful information.  Example: Suppose you are
rolling a standard 6-sided die, and you do not want to roll a 6.  The numbers 1
to 5 are "good apples" and the number 6 is a "poisoned apple."  If you roll the
die 3 times (think of this as picking apples with replacement), the probability
of not rolling a 6 is .579.  The list displayed is {.833, .694, .579} since
these numbers are the probabilities of not rolling a 6 in the first one, two,
and three rolls, respectively.

6: Run of Success
Suppose there are two possible outcomes to an event, a "loss" and a "win," and
you have a P probability of getting a win on any given trial.  Suppose you do
several trials, and you want to always have at least as many wins as losses.
This program computes the probability of that happening.  Example:  Imagine you
are playing a game where you get 1 point each time a pollywolly doodles, and -1
point each time a pollywolly doesn't doodle.  Suppose the pollywolly has a 
probability .8 of doodling each time, and you want to always have at least 0
points total, until N=8 events have happened (a pollywolly doodling or not).
The probability of never getting a negative score is .754.  The program also
displays a list that shows the probability of a "continued win majority" for
each number up to N, and displays the probability of always having more wins
than losses with infinite trials.

7: Formulas
This has a few formulas related to a certain type of situation.  The situation
is k bins containing n balls.  The balls can be either distinguishable or
indistinguishable from one another, as the bins can be.  These formulas give
the total number of possible distributions in each of these scenarios (except
dist. balls and indist. bins).  Many counting problems can be modeled as one
of these ball-and-bin scenarios.

Feel free to contact me with any questions or comments at rgaebler@hmc.edu.