Feb 20: Bayes' Rule, Expectation and Variance How we design this - - PowerPoint PPT Presentation
Feb 20: Bayes' Rule, Expectation and Variance How we design this - - PowerPoint PPT Presentation
Feb 20: Bayes' Rule, Expectation and Variance How we design this course 1. Learning goals 2. Homework that tests learning goals 3. Lectures and sessions that provide tools to do homework that tests learning goals if something seems hard,
How we design this course
1. Learning goals 2. Homework that tests learning goals 3. Lectures and sessions that provide tools to do homework that tests learning goals if something seems hard, look for the hidden clues!
Source: Nintendo, shacknews.com
How to stay out of trouble on homework
Integrity: ... You may discuss homework problems, but you have to write your
- wn answers by yourself. You may
consult online forums or look at examples, but you cannot copy text or code from them. You are not helping your friend by allowing them to not learn. ...
Contingency tables
red blue circle square
Normalize to joint probability P(Shape, Color)
red blue circle square red blue circle 1/3 1/4 square 1/6 1/4
Normalize to joint probability P(Shape, Color)
red blue circle square red blue circle 1/3 1/4 square 1/6 1/4
"Normali{e" = Divide everything by the total sum
Normalization loses information
red blue circle 1/3 1/4 square 1/6 1/4
Normalization loses information
red blue circle square red blue circle 1/3 1/4 square 1/6 1/4
Normalization loses information
red blue circle square red blue circle 1/3 1/4 square 1/6 1/4
Normalization loses information
red blue circle square red blue circle 1/3 1/4 square 1/6 1/4
Four free parameters Tiree free parameters
Marginal probabilities sum over one axis
P(S,C) red blue circle square P(S) circle 7/12 square 5/12 P(C) red blue 6/12 6/12 Axis 0 Axis 1
Divide joint by marginal to get conditionals
red blue circle 1/3 1/4 square 1/6 1/4 red blue 1/2 1/2 red cir cle 2/3 squ are 1/3 blue cir cle 1/2 squ are 1/2 / =
"Normali{e" = Divide everything by the total sum
Divide joint by marginal to get conditionals
red blue circle 1/3 1/4 square 1/6 1/4 red blue 1/2 1/2 red cir cle 2/3 squ are 1/3 blue cir cle 1/2 squ are 1/2 / =
P(Shape, Color) P(Color)
=
P(Shape | Color)
"Given"
Which is larger? P(Shape=square, Color=blue)
- r
P(Shape=square | Color=blue)
Multiply conditionals by marginal to get joint
red blue circle 1/3 1/4 square 1/6 1/4 red blue 1/2 1/2 red cir cle 2/3 squ are 1/3 blue cir cle 1/2 squ are 1/2 = *
P(Shape, Color)
=
P(Shape | Color) P(Color)
Divide by marginal going the other way
red blue circle 1/3 1/4 square 1/6 1/4 circle 7/12 square 5/12 red blue circle 4/7 3/7 = / red blue square 2/5 3/5
Divide by marginal going the other way
red blue circle 1/3 1/4 square 1/6 1/4 circle 7/12 square 5/12 red blue circle 4/7 3/7 = / red blue square 2/5 3/5
P(Shape, Color) P(Shape)
=
P(Color | Shape)
Bayes' Rule!
red blue circle 1/3 1/4 square 1/6 1/4 circle 7/12 square 5/12 red blue circle 4/7 3/7 = / red blue square 2/5 3/5
= P(Color | Shape)
red blue 1/2 1/2 red cir cle 2/3 squ are 1/3 blue cir cle 1/2 squ are 1/2 *
P(Shape | Color) P(Color) P(Shape)
=
What we did to load section data
Read multiple files from CSV Extract values from filenames with regular expressions Change variable types (int -> string) Extract new variables from existing variables with regular expressions Recode four-value variable to two values Count co-occurrences of two variables (section, grade level)
What does it feel like to have a bug in code?
Strange things keep happening, but you will
- fuen be able to "explain
away" results. At first. TRUST YOUR GUT. BE VIRTUOUS. BE PARANOID.