07: Variance, Bernoulli, Binomial Lisa Yan April 20, 2020
1 Quick slide reference
3 Variance 07a_variance_i
10 Properties of variance 07b_variance_ii
17 Bernoulli RV 07c_bernoulli
22 Binomial RV 07d_binomial
34 Exercises LIVE
Lisa Yan, CS109, 2020 2 07a_variance_i
Variance
3 Average annual weather Stanford, CA Washington, DC � high = 68°F � high = 67°F � low = 52°F � low = 51°F
Is � � enough?
Lisa Yan, CS109, 2020 4 Average annual weather Stanford, CA Washington, DC � high = 68°F � high = 67°F � low = 52°F � low = 51°F Stanford high temps Washington high temps 0.4 0.4 68°F 67°F 0.3 0.3 � �
= 0.2 = 0.2 � �
� 0.1 � 0.1
0 0 35 50 65 80 90 35 50 65 80 90 Normalized histograms are approximations of PMFs.
Lisa Yan, CS109, 2020 5 Variance = “spread” Consider the following three distributions (PMFs):
• Expectation: � � = 3 for all distributions • But the “spread” in the distributions is different! • Variance, Var � : a formal quantification of “spread”
Lisa Yan, CS109, 2020 6 Variance
The variance of a random variable � with mean � � = � is
Var � = � � − � !
• Also written as: � � − � � • Note: Var(X) ≥ 0 • Other names: 2nd central moment, or square of the standard deviation
Var � Units of � def standard deviation SD � = Var � Units of �
Lisa Yan, CS109, 2020 7 Var � = � � − � � ! Variance Variance of Stanford weather of � Stanford, CA � high = 68°F � � − � � low = 52°F 57°F 124 (°F)2 Stanford high temps 71°F 9 (°F)2 0.4 2 � � = � = 68 75°F 49 (°F) 0.3 69°F 1 (°F)2 �
= 0.2 … … �
� 0.1 Variance � � − � = 39 (°F)2 0 35 50 65 80 90 Standard deviation = 6.2°F
Lisa Yan, CS109, 2020 8 Var � = � � − � � ! Variance Comparing variance of � Stanford, CA Washington, DC � high = 68°F � high = 67°F
Stanford high temps Washington high temps 0.4 0.4 68°F 67°F 0.3 0.3 � �
= 0.2 = 0.2 � �
� 0.1 � 0.1
0 0 35 50 65 80 90 35 50 65 80 90 Var � = 39 °F Var � = 248 °F
Lisa Yan, CS109, 2020 9 07b_variance_ii
Properties of Variance
10 Properties of variance
Definition Var � = � � − � � Units of � def standard deviation SD � = Var � Units of �
Property 1 Var � = � � − � � Property 2 Var �� + � = � Var �
• Property 1 is often easier to compute than the definition • Unlike expectation, variance is not linear
Lisa Yan, CS109, 2020 11 Properties of variance
Definition Var � = � � − � � Units of � def standard deviation SD � = Var � Units of �
Property 1 Var � = � � − � � Property 2 Var �� + � = � Var �
• Property 1 is often easier to compute than the definition • Unlike expectation, variance is not linear
Lisa Yan, CS109, 2020 12 Var � = � � − � � ! Variance Computing variance, a proof = � �! − � � ! of �