Open In Colab

Probability

Introduction

Probability is essential to the way we think about the world. We know that most things are uncertain and we must quantify that uncertainty if we hope to operate in our fast paced world. Quantifying and utilizing this uncertainty is used in gambling, insurance, networking, and all sorts of industries. A basic understanding of the theoretical underpinnings of probability will help you navigate these topics.

Theory

In probability, we call an event a collection of possible outcomes. A simple event is an event that cannot be decomposed any further. Simple events for probability are very important in that each one will be assigned a probability AND the sum of all those probabilities must some to one. We call the collection of all simple events the universal set, \(U\).

Examples

Oklahoma Weather

The weather on a fall day in Oklahoma has a wide variety of possible temperatures.

Temperature

Probability

\(95^\circ\)

10%

\(85^\circ\)

20%

\(75^\circ\)

40%

\(65^\circ\)

20%

\(55^\circ\)

10%

Our universal set will consist of \(U = \{95^\circ,85^\circ,75^\circ,65^\circ,55^\circ\}\) and the sum of the probabilities is 1 or 100%.

We can ask some questions simply using this table. What is the probability that the temperature will be 95 or 85? We can simply add the probability of these two simple events as either could happen. So there is a 30% chance of the temperature being 95 or 85.

If instead we asked what is the likelihood that the temperature was 95 and 85. Since the events are simple, there is no overlap! This means that this event is impossible and the probability will be 0.

Coding a random day like this will be done with the random package.

import random

random.choices([95,85,75,65,55],[10,20,40,20,10], k = 5)
[65, 75, 85, 85, 75]

The code above simulated 5 days, using our probabilities. Note that random choices does not require the probabilities to sum to 1 or even 100.

Expected Oklahoma Weather

One of the most important ideas of probability is the random variable. For our example, this was the temperature. We see above that that varied as we had differing conditions. The random variable also gives us the idea of expected value This is someways related to the mean (or average) but uses the probabilities to be computed. We compute the expected value as the sum of the probability times its respective random variable.

\[ E[x] = \sum_{i=1}^np_ix_i \]

We apply this to our weather $\( 95*.1+85*.2+75*.4+65*.2+55*.1 = 75 \)$

The expected value need not give a value in your universal set!

This expected value can be achieved by taking an average of our outcomes from the random choices.

k = 10000

choice = random.choices([95,85,75,65,55],[10,20,40,20,10], k = k)

sum(choice)/k
75.016

Of course this won’t be exact but will give us a great indication of where our expected value is. To get the expected value in a non-random way we would do something like:

temp = [95,85,75,65,55]
prob = [.10,.20,.40,.20,.10]
e = 0
for i in range(len(temp)):
  e+= temp[i]*prob[i]

e
75.0

References

How to Solve It G. Polya Second Edition Princeton University Press 1957

Thinking Mathematically J. Mason Addison-Wesley Publishing Company 1985

Grit: The Power of Passion and Perseverance A. Duckworth ‎ Scribner Book Company 2016

Problems

Project Idea

Authors

Principal authors of this chapter were: N.C.Jacob, but you!

Contributions were made by: