Probability and Events

Probability is mathematical study that models the uncertainty of outcomes on random events. Largely used in statistics, it is powerful way of modeling random variables and determining potential outcomes of results given the known information about some random event.

In this introduction, I introduce the general terminology and basic computation for probability.

Let's begin with an intiutive idea. Suppose I have a coin and I'm interesting you in a bet. If the coin is flipped and the results is heads, I will give you $ 50. However, if the coin toss lands on tails, you have to give me 50 bucks. What would you do?

The most important question in the experiment above is determining how likely the results would be heads or tails. In order to mathematically formulate the probability, we need to have the following concepts defined.

  1. $Sample\ Space\ - \Omega$: all possible outcomes of the experiment. The sample is also considered as collectively exhaustive as it contains all possible outcomes.
    For example: A fair coin sample space is:

    $$ \Omega = (Heads, Tails) $$

  2. $Probabilities - \mathcal {P}(x)$ The probabilities associated with the all the elements in the sample space. In the case above:


    $$ \mathcal {P}(x) = \frac {occurance\ of\ event\ A}{number\ of\ elements\ in\ sample\ space} = (\frac{1}{2}, \frac {1}{2}) $$


What is probability?

Formally, probability of some event A happening is the total number of ways that A can happen over the total number of ways that other equally likely possibilities can happen.

Example: Assuming that there are only three possible weather events tomorrow all of which are equally likely: rainy, sunny or cloudy. What is the probability that it will rain tomorrow?

Mathematically:

$$\mathcal {P}(rain) = \frac {number\ of\ possible\ rain \ outcome} {all\ possible\ weather\ outcomes} = \frac {1}{3}$$

Example:

Suppose a die is rolled, what is the probability of getting an even number? Before we can answer this question, let's formalize the concept of events.

Events

An event is defined as the subset of all possible outcomes of an experiment. For example: Suppose we flip a fair coin twice, we know that the sample space of our experiment is given by:

$$\Omega = (HH,TT,HT,TH) $$

Suppose A is an event defined as: 2nd flip is heads, then event A is mathematically expressed as:

$$A=(HH,TH)$$

Suppose B is an event defined as: at least one flip is tails, then event B is a subset containing: $$B=(HT,TT,TH)$$

Now back to the questions, what is the probability of getting an even number? Let's use some python code to compute this.

def compute_probability(sample_space, events):
    """ Compute Simple Probility """
    return round(len(events)/len(sample_space), 2)

We know that our sample space is outcomes 1-6 and our events are 2, 4, 6. We just add them to this function.

compute_probability([1, 2, 3, 4, 5, 6], [2, 4, 6])
.5

This concludes the introduction to Probability and Events. In the next sections, we cover advanced topics that extend the concepts above