~/ learn/ afm-113/ cards/ Expected value and variance of a discrete random variable
1 of 6

Compute E[X], E[X²], the variance by the shortcut and the SD for the batch pmf {0: 0.40, 1: 0.35, 2: 0.15, 3: 0.10}.

Compute E[X], E[X²], the variance by the shortcut and the SD for the batch pmf {0: 0.40, 1: 0.35, 2: 0.15, 3: 0.10}.

Answer

import math pmf = {0: 0.40, 1: 0.35, 2: 0.15, 3: 0.10} mean = sum(x * p for x, p in pmf.items()) ex2 = sum(x * x * p for x, p in pmf.items()) var = ex2 - mean ** 2 print(f"E={mean:.4f} E[X^2]={ex2:.4f} Var={var:.4f} SD={math.sqrt(var):.4f}")

IS1 §4.2 (expected value, table method, expected-profit shapes), CC BY 4.0 — shape only; original dataset

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/7d2b4c5f-4a1a-4e9e-af7b-ae50bd054f9c/flashcard utf-8 LF