Table of contents
1.
Introduction
2.
Expectation
3.
Variance
4.
Key Takeaways
Last Updated: Mar 27, 2024

Expectation and Variance - Discrete Random Variable

Author soham Medewar
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Before moving onto the main topic, let us discuss random variables and their types. A random variable is a term where the output depends on the random phenomenon. The three types of random variables are singular, continuous, discrete.

A random variable with a countable number of possible values is called a discrete random variable. The discrete random variables can have either a finite set or a countable number of discrete variables. The probability of every value in the discrete random variable is between 0 to 1. The sum of all the probabilities is equal to 1. For example, the number of children in a family, the number of chairs in a room, etc.

Expectation

The expectation is also an expected value of a random variable. It tells you about the behavior of a random variable. We can say expectation as an average value of the random variables, where each value is weighted according to its probability. 

Suppose X is a discrete random variable with values x1, x2, x3, x4, … xn. The probability of every xi is P(xi) (1 ≤ i ≤ n). The expected value of the random variable X is E(X), defined by

Example 1. Find E(X) for the random variable X given in the table below:

Value of X 1 5 8
p.m.f 3/10 1/2 2/10

Solution: E(X) = 1*(3/10) + 5*(1/2) + 8*(2/10) = 4.4

Example 2. Roll two unbiased 6-sided dice. You win $800 if the sum is 3 and lose $50 otherwise. How much do you expect to win on average per trial?

Solution: The probability of getting sum = 3 is 2/36 because you can either get (1, 2) or (2, 1) to get a sum equal to 3.

                 Then the probability of not getting the sum = 3 will be 34/36.

                 If you play N times, you can expect N*(2/36) of getting sum equal to 3 and N*(34/36) of getting sum not equal to 3.

                 Thus your expected winnings will be:

                 800*(2/36)N - 50*(34/36)N = -$2.78N

                  Now divide it by N to get the expected average per trial.

                  -$2.78 will be the expected average per trial.

Example 3. Suppose we have a die with six faces marked with four 2’s, one 3, and one 6. What would you expect the average of 12000 rolls to be?

Solution: The probability of getting 2 is 4/6.

                 The probability of getting 3 is 1/6.

                 The probability of getting 6 is 1/6.

Value of X 2 3 6
Expected count (4/6)*12000 = 8000 (1/6)*12000 = 2000 (1/6)*12000 = 2000

Expected average of these 12000 rolls will be

(8000*2 + 2000*3 + 2000*6) / 12000 = 2.83

Expected average of 12000 rolls = 2.83

Variance

The variance is the statistical measurement that gives the information of spread between two numbers in the dataset. Variance is denoted by the symbol 𝞼2. In other words, variance gives the degree of spread in the dataset; the more spread is the data, the larger is the variance is.

Steps to find variance.

  • First, find the mean(average) of the dataset.

  • Calculate the squared difference of mean and all the datapoints.

  • Calculate the sum of squared differences.

  • Now divide the sum by the size of the dataset, i.e., n. Here ߎ is the mean.

Example 1. Calculate the variance for the following data points.

xi = 53, 26, 96, 44, 85, 23, 55, 69, 88, 74, 56

Solution: 

xi (x- u)2
53 193.21
26 1672.81
96 846.81
44 524.41
85 327.61
23 1927.21
55 141.61
69 4.41
88 445.21
74 50.41
56 118.81
∑xi = 66.9 ∑(x- u)2 = 6525.51

Therefore variance (𝞼2) = 6525.51/10 = 652.551

Example 2. Find the variance of the below table.

Salary No. of Employees
50000 - 75000 5
75001- 100000 3
100001 - 125000 2
125001 - 150000 6
150001 - 175000 4

Solution:

For this type of problem, we need a different formula to calculate variance.

source

  • 𝞼2 = variance
  • fi = frequency of employee
  • xi = mid value
  • di = (xi - A)/h (A = any random value)
  • N = total number of employees
  • h = upper limit - lower limit (of any salary)
Salary No. of Employees (fi) Mid value(xi) di = (xi - A)/h fidi fi*di2
50001 - 75000 5 62500.5 -2 -10 20
75001- 100000 3 87500.5 -1 -3 3
100001 - 125000 2 112500.5 ( = A) 0 0 0
125001 - 150000 6 137500.5 1 6 6
150001 - 175000 4 162500.5 2 8 16
  ∑fi = 20     ∑fi*di = 1 ∑fi*di2 = 45

Therefore, the variance of salaries of 20 employees will be  ≅1404687500.

Key Takeaways

In this article we have covered:

  • Discrete random variables
  • Expectation or expected value of discrete random variables
  • Variance of discrete random variables
  • Solved Examples


Check out this problem - Subarray Sum Divisible By K


Hello readers, here's a perfect course that will guide you to dive deep into Machine learning.

Happy Coding!

Live masterclass