What is the probability distribution function of the number of heads when a fair coin is tossed once?

  • Definition--A random variable is a quantitative variable whose value is determined by some chance mechanism.  Examples are the total number of heads in 10 tosses of a fair coin, the toss number of the first head in 10 tosses of a fair coin, the number of red balls selected when drawing 2 balls (without replacement) from a container that holds 8 red balls and 20 green balls.
  • Discrete and Continuous Random Variables
    • Discrete random variables can only have a finite or countably infinite number of values.  The number of heads in 10 tosses of a fair coin, the toss number of the first head if a fair coin is tossed until a head appears, or the number of green balls selected in the example given above.
    • Continuous random variables can assume any of an uncountably infinite set of values.  For example, if a point is picked at random on the interval from [0,1], there are an uncountably infinite number of values that could be picked.
  • Probability Distribution of a Discrete Random Variable--Each discrete random variable can only assume a finite or countably infinite number of values.  If a table is made associating the probability of each value with the value, the table or association is the probability distribution of that random variable.  As an example consider tossing a fair coin 3 times.  A random variable that can be associated with this experiment is a count of the number of heads in the 3 tosses.  Call this random variable T.  T can assume any of the values 0, 1, 2, or 3.  The probabilities associated with each of these values are P[T=0]=1/8, P[T=1]=3/8, P[T=2]=3/8, and P[T=3]=1/8.  These probabilities make up the probability distribution of this random variable.  In table form, this probability distribution is:

    t

    0

    1 2 3
    P[T=t] 1/8 3/8 3/8 1/8


    Notice that the sum of the probabilities is 1.  This is true for any discrete random variable. 

    Run the experiment of tossing a fair coin 3 times 1000 times updating after every 100 tosses.  To do this link here, and when the page opens click the red die in front of number 4.  Set the number of coins at 3.  After running the experiment 1000 times, what can you say about the theoretical (in blue) and actual (in red) probability distributions of the number of heads?

    In all examples of discrete random variables, the probabilities in the probability distribution table give the 'long-term' proportion of times that the random variable assumes each possible value.

  • Example 1: Find the probability distribution of the number of red balls selected if two balls are selected (without replacement) from a container which has 4 balls numbered 1 through 4, with balls numbered 1 and 2 red balls and balls numbered 3 and 4 green balls.
  • Example 2: Find the probability distribution of the number of red balls selected if two balls are selected (with replacement) from a container which has 4 balls numbered 1 through 4, with balls numbered 1 and 2 red balls and balls numbered 3 and 4 green balls.
  • Example 3: Find the probability distribution of the number of red balls selected if two balls are selected (with replacement) from a container with 20 balls, 10 of them red and 10 green.
  • Example 4: Find the probability distribution of the number of red balls selected if two balls are selected (without replacement) from a container with 20 balls, 10 of them red and 10 green.

    For examples 3 and 4, you can use this link to a simulation of the situation.  When the page opens click the red die in front of number 4 to open the simulation.  When the simulation opens, set N to 20, set R to 10, the number of red balls, and set n, the sample size to 2.  Select with or without replacement as appropriate for the example.  The blue graph and the text below it will show probabilities for each number of red balls.

  • Example 5: In examples 3 and 4 decrease the number of red balls.  What happens to the probability distribution of the number of red balls in the sample?  Is this expected?  Also, for each number of red balls, observe the differences in the probability distribution with and without replacement.  Next, set the number of red balls at 10, use sampling with or without replacement, and run the simulation of drawing 2 balls, 1000 times, updating every 100 times.  What do you see?
  • Mean (also called Expected Value) and Standard Deviation of a Discrete Random Variable

    Consider again the count of heads in 3 tosses of a fair coin.  If this experiment is repeated, say 10 times, and the number of heads in each series of 3 tosses is counted, you will have a set of numbers like 0,1,3,1,2,2,1,1,3,0.  The average of these numbers is the average value for the random variable, the number of heads in 3 tosses of a fair coin.  To see what happens in a larger number of runs of the experiment, again link here, and when the page opens click the red die in front of number 4.  Set the number of coins at 3 and run the experiment 100 times.  What is the average number of heads per 3 tosses?  Now reset and run the experiment 1000 times.  What is the average number of heads per 3 tosses?

    The long-term average number of heads is called the expected value of the random variable, the number of heads in 3 tosses of a fair coin.  This expected value can be found for most random variables.  Think of expected value as the average value of a random variable.

    There is an easier way to find the expected value of this (or any) discrete random variable.  If the experiment of tossing the coin 3 times is repeated for a large number, N, times, the experiment will end in 0 heads n0 times, in 1 head n1 times, in 2 heads n2 times, and in 3 heads n3 times.  The total number of heads is 0 n0 + 1 n1 + 2 n2 + 3 n3, and the average number of heads per run of the experiment is

    (0 n0 + 1 n1 + 2 n2 + 3 n3)/N = 0 (n0/N) + 1 (n1/N) + 2 (n2/N) + 3 (n3/N)

    For large N, (n0/N) ~ P[0 Heads], (n1/N) ~ P[1 Head], (n2/N) ~ P[2 Heads], (n3/N) ~ P[3 Heads], so the average number of heads per run of the experiment is

    0 P[0 Heads] + 1P[1 Head] + 2 P[2 Heads] + 3 P[3 Heads]

    This is called the Expected Value or Mean and is denoted, for a general random variable X, by E[X].  It can be computed by

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    Using this formula on the random variable T, the total number of heads in 3 tosses of a fair coin, you get

    µ=E[T] = 0 (1/8) + 1 (3/8) + 2 (3/8) + 3 (1/8) = 12/8 = 3/2 = 1.5.  This can be interpreted as the average number of heads per sequence of 3 tosses if the experiment is repeated a large number of times.

    Just as you are able to find the average value for a random variable, so you can also find the standard deviation of the random variable.  In the case of a random variable, the standard deviation is given by

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    For random variable T, the total number of heads in 3 tosses of a fair coin, the standard deviation computed by the rightmost formula is

    SD[T] = Square Root of [02 (1/8) + 12 (3/8) + 22 (3/8) + 32 (1/8) - (3/2)2] = Square Root of [3/4] = 31/2/2

  • What is the probability distribution function of the number of heads when a fair coin is tossed once?

    "Bi" means "two" (like a bicycle has two wheels) ...
    ... so this is about things with two results.

    What is the probability distribution function of the number of heads when a fair coin is tossed once?
       

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    Tossing a Coin:

    • Did we get Heads (H) or
    • Tails (T)

    We say the probability of the coin landing H is ½
    And the probability of the coin landing T is ½

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    Throwing a Die:

    • Did we get a four ... ?
    • ... or not?

    We say the probability of a four is 1/6 (one of the six faces is a four)
    And the probability of not four is 5/6 (five of the six faces are not a four)

    Note that a die has 6 sides but here we look at only two cases: "four: yes" or "four: no"

    Toss a fair coin three times ... what is the chance of getting exactly two Heads?

    Using H for heads and T for Tails we may get any of these 8 outcomes:

    HHH  
    What is the probability distribution function of the number of heads when a fair coin is tossed once?
    HHT  
    What is the probability distribution function of the number of heads when a fair coin is tossed once?
    HTH  
    HTT  
    THH  
    THT  
    TTH  
    TTT  

    Which outcomes do we want?

    "Two Heads" could be in any order: "HHT", "THH" and "HTH" all have two Heads (and one Tail).

    So 3 of the outcomes produce "Two Heads".

    What is the probability of each outcome?

    Each outcome is equally likely, and there are 8 of them, so each outcome has a probability of 1/8

    So the probability of event "Two Heads" is:

    Number of
    outcomes we want
        Probability of
    each outcome
     
    3   ×   1/8   =  3/8

    So the chance of getting Two Heads is 3/8

    We used special words:

    • Outcome: any result of three coin tosses (8 different possibilities)
    • Event: "Two Heads" out of three coin tosses (3 outcomes have this)

    3 Heads, 2 Heads, 1 Head, None

    The calculations are (P means "Probability of"):

    • P(Three Heads) = P(HHH) = 1/8
    • P(Two Heads) = P(HHT) + P(HTH) + P(THH) = 1/8 + 1/8 + 1/8 = 3/8
    • P(One Head) = P(HTT) + P(THT) + P(TTH) = 1/8 + 1/8 + 1/8 = 3/8
    • P(Zero Heads) = P(TTT) = 1/8

    We can write this in terms of a Random Variable "X" = "The number of Heads from 3 tosses of a coin":

    • P(X = 3) = 1/8
    • P(X = 2) = 3/8
    • P(X = 1) = 3/8
    • P(X = 0) = 1/8

    And this is what it looks like as a graph:

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    It is symmetrical!

    Making a Formula

    Now imagine we want the chances of 5 heads in 9 tosses: to list all 512 outcomes will take a long time!

    So let's make a formula.

    In our previous example, how can we get the values 1, 3, 3 and 1 ?

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    Well, they are actually in Pascal’s Triangle !

    Can we make them using a formula?

    Sure we can, and here it is:

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    The formula may look scary but is easy to use. We only need two numbers:

    • n = total number
    • k = number we want

    The "!" means "factorial", for example 4! = 1×2×3×4 = 24

    Note: it is often called "n choose k" and you can learn more here.

    Let's try it:

    We have n=3 and k=2:

    n!k!(n-k)! =3!2!(3-2)!

    =3×2×12×1 × 1

    = 3

    So there are 3 outcomes that have "2 Heads"

    (We knew that already, but we now have a formula for it.)

    Let's use it for a harder question:

    We have n=9 and k=5:

    n!k!(n-k)! =9!5!(9-5)!

    =9×8×7×6×5×4×3×2×15×4×3×2×1 × 4×3×2×1

    =126

    So 126 of the outcomes will have 5 heads

    And for 9 tosses there are a total of 29 = 512 outcomes, so we get the probability:

    Number of
    outcomes we want
      Probability of
    each outcome
       
    126   ×   1512   =   126512

    So:

    P(X=5)  =  126512  = 0.24609375 

    About a 25% chance.

    (Easier than listing them all.)

    Bias!

    So far the chances of success or failure have been equally likely.

    But what if the coins are biased (land more on one side than another) or choices are not 50/50.

    This is just like the heads and tails example, but with 70/30 instead of 50/50.

    Let's draw a tree diagram:

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    The "Two Chicken" cases are highlighted.

    The probabilities for "two chickens" all work out to be 0.147, because we are multiplying two 0.7s and one 0.3 in each case. In other words

    0.147 = 0.7 × 0.7 × 0.3

    Or, using exponents:

    = 0.72 × 0.31

    The 0.7 is the probability of each choice we want, call it p

    The 2 is the number of choices we want, call it k

    And we have (so far):

    = pk × 0.31

    The 0.3 is the probability of the opposite choice, so it is: 1−p

    The 1 is the number of opposite choices, so it is: n−k

    Which gives us:

    = pk(1-p)(n-k)

    Where

    • p is the probability of each choice we want
    • k is the the number of choices we want
    • n is the total number of choices

    • p = 0.7 (chance of chicken)
    • k = 2 (chicken choices)
    • n = 3 (total choices)

    So we get:

    pk(1-p)(n-k) =0.72(1-0.7)(3-2)

    =0.72(0.3)(1)

    =0.7 × 0.7 × 0.3

    =0.147

    which is what we got before, but now using a formula

    Now we know the probability of each outcome is 0.147

    But we need to include that there are three such ways it can happen: (chicken, chicken, other) or (chicken, other, chicken) or (other, chicken, chicken)

    The total number of "two chicken" outcomes is:

    n!k!(n-k)! =3!2!(3-2)!

    =3×2×12×1 × 1

    =3

    And we get:

    Number of
    outcomes we want
        Probability of
    each outcome
       
    3   ×   0.147   =   0.441

    So the probability of event "2 people out of 3 choose chicken" = 0.441

    OK. That was a lot of work for something we knew already, but now we have a formula we can use for harder questions.

    So we have:

    And we get:

    pk(1-p)(n-k) =0.77(1-0.7)(10-7)

    =0.77(0.3)(3)

    =0.0022235661

    That is the probability of each outcome.

    And the total number of those outcomes is:

    n!k!(n-k)!  =10!7!(10-7)!

    =10×9×8×7×6×5×4×3×2×17×6×5×4×3×2×1 × 3×2×1

    =10×9×83×2×1

    =120

    And we get:

    Number of
    outcomes we want
        Probability of
    each outcome
       
    120   ×   0.0022235661   =   0.266827932

    So the probability of 7 out of 10 choosing chicken is only about 27%

    Moral of the story: even though the long-run average is 70%, don't expect 7 out of the next 10.

    Putting it Together

    Now we know how to calculate how many:

    n!k!(n-k)!

    And the probability of each:

    pk(1-p)(n-k)

    When multiplied together we get:

    Probability of k out of n ways:

    P(k out of n) =  n!k!(n-k)! pk(1-p)(n-k)

    The General Binomial Probability Formula

    Important Notes:

    • The trials are independent,
    • There are only two possible outcomes at each trial,
    • The probability of "success" at each trial is constant.

    Quincunx

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    Have a play with the Quincunx (then read Quincunx Explained) to see the Binomial Distribution in action.

    A fair die is thrown four times. Calculate the probabilities of getting:

    • 0 Twos
    • 1 Two
    • 2 Twos
    • 3 Twos
    • 4 Twos

    In this case n=4, p = P(Two) = 1/6

    X is the Random Variable ‘Number of Twos from four throws’.

    Substitute x = 0 to 4 into the formula:

    P(k out of n) =  n!k!(n-k)! pk(1-p)(n-k)

    Like this (to 4 decimal places):

    • P(X = 0) = 4!0!4! × (1/6)0(5/6)4 = 1 × 1 × (5/6)4 = 0.4823
    • P(X = 1) = 4!1!3! × (1/6)1(5/6)3 = 4 × (1/6) × (5/6)3 = 0.3858
    • P(X = 2) = 4!2!2! × (1/6)2(5/6)2 = 6 × (1/6)2 × (5/6)2 = 0.1157
    • P(X = 3) = 4!3!1! × (1/6)3(5/6)1 = 4 × (1/6)3 × (5/6) = 0.0154
    • P(X = 4) = 4!4!0! × (1/6)4(5/6)0 = 1 × (1/6)4 × 1 = 0.0008

    Summary: "for the 4 throws, there is a 48% chance of no twos, 39% chance of 1 two, 12% chance of 2 twos, 1.5% chance of 3 twos, and a tiny 0.08% chance of all throws being a two (but it still could happen!)"

    This time the graph is not symmetrical:

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    It is not symmetrical!

    It is skewed because p is not 0.5

    What is the probability distribution function of the number of heads when a fair coin is tossed once?

    Sports Bikes

    Your company makes sports bikes. 90% pass final inspection (and 10% fail and need to be fixed).

    What is the expected Mean and Variance of the 4 next inspections?

    First, let's calculate all probabilities.

    X is the Random Variable "Number of passes from four inspections".

    Substitute x = 0 to 4 into the formula:

    P(k out of n) =  n!k!(n-k)! pk(1-p)(n-k)

    Like this:

    • P(X = 0) = 4!0!4! × 0.900.14 = 1 × 1 × 0.0001 = 0.0001
    • P(X = 1) = 4!1!3! × 0.910.13 = 4 × 0.9 × 0.001 = 0.0036
    • P(X = 2) = 4!2!2! × 0.920.12 = 6 × 0.81 × 0.01 = 0.0486
    • P(X = 3) = 4!3!1! × 0.930.11 = 4 × 0.729 × 0.1 = 0.2916
    • P(X = 4) = 4!4!0! × 0.940.10 = 1 × 0.6561 × 1 = 0.6561

    Summary: "for the 4 next bikes, there is a tiny 0.01% chance of no passes, 0.36% chance of 1 pass, 5% chance of 2 passes, 29% chance of 3 passes, and a whopping 66% chance they all pass the inspection."

    Mean, Variance and Standard Deviation

    Let's calculate the Mean, Variance and Standard Deviation for the Sports Bike inspections.

    There are (relatively) simple formulas for them. They are a little hard to prove, but they do work!

    The mean, or "expected value", is:

    μ = np

    For the sports bikes:

    μ = 4 × 0.9 = 3.6

    So we can expect 3.6 bikes (out of 4) to pass the inspection.
    Makes sense really ... 0.9 chance for each bike times 4 bikes equals 3.6

    The formula for Variance is:

    Variance: σ2 = np(1-p)

    And Standard Deviation is the square root of variance:

    σ = √(np(1-p))

    For the sports bikes:

    Variance: σ2 = 4 × 0.9 × 0.1 = 0.36

    Standard Deviation is:

    σ = √(0.36) = 0.6

    Note: we could also calculate them manually, by making a table like this:

    X P(X) X × P(X) X2 × P(X)
    0 0.0001 0 0
    1 0.0036 0.0036 0.0036
    2 0.0486 0.0972 0.1944
    3 0.2916 0.8748 2.6244
    4 0.6561 2.6244 10.4976
      SUM: 3.6 13.32

    The mean is the Sum of (X × P(X)):

    μ = 3.6

    The variance is the Sum of (X2 × P(X)) minus Mean2:

    Variance: σ2 = 13.32 − 3.62 = 0.36

    Standard Deviation is:

    σ = √(0.36) = 0.6

    And we got the same results as before (yay!)

    Summary

    • The General Binomial Probability Formula:

      P(k out of n) =  n!k!(n-k)! pk(1-p)(n-k)

    • Mean value of X: μ = np
    • Variance of X: σ2 = np(1-p)
    • Standard Deviation of X: σ = √(np(1-p))

    8815, 8816, 8820, 8821, 8828, 8829, 8609, 8610, 8612, 8613, 8614, 8615

    Copyright © 2022 Rod Pierce