Lecture notes‎ > ‎

Lecture 04

For today you should have:
  1. Done Homework 3.
  1. Practice quiz.
  2. Are you popular?
  3. Distribution of percentiles.
  4. Python style.
  5. myplot.py
For next time:
  1. Read Chapter 4.
  2. Prepare for a quiz on Chapters 1-3.  Note: you will be allowed to use anything in the Pmf and Cdf APIs.

Practice quiz

1) Exercise 3-1.

2) When statisticians talk about income and wealth, they almost always use medians and other percentiles rather than means.  Why?

For this and other short-answer questions, you should write 1-2 complete sentences that would be understood by an intelligent adult with only casual knowledge of statistics.

3) For the set of values {1, 2, 2, 3, 3, 3, 4, 4, 4, 4}, what is CDF(3)?  What is the 30th percentile?  What is the 40th percentile?

Are you popular?

Hint: No.

Write a function that takes two PMFs and returns the probability that a value drawn from the first distribution will be greater than a value from the second distribution.


Distribution of percentiles?



How does this lead us to an algorithm for generating random numbers from an arbitrary CDF?

Python style

You should almost certainly adopt the style guidelines here: http://www.python.org/dev/peps/pep-0008/

In addition, I recommend the style guidelines here: http://google-styleguide.googlecode.com/svn/trunk/pyguide.html


Take a look at myplot.py (documentation at myplot.html).

Here's an example of how to use myplot.Plot

import myplot
import matplotlib.pyplot as pyplot

    pyplot.plot(xs, ps)
              title='Exponential CDF',

Generates files named expo_cdf.eps and expo_cdf.png

Note that homework 4 asks you to generate EPS files and put them in the shared directory.

One more Bayes's Theorem problem

If you meet a man with (naturally) red hair, what is the probability that neither of his parents has red hair?
Hints: About 2% of the world population has red hair.  You can assume that the alleles for red hair are purely recessive.  Also, you can assume that the Red Hair Extinction theory is false, so you can apply the Hardy–Weinberg principle.