Lecture notes‎ > ‎

### Lecture 04

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

## Distribution of percentiles?

Suppose you and your classmates compute the percentile rank of your birth weights and then compute the CDF of the percentile ranks. What do you expect it to look like?

Hint: what fraction of the class do you expect to be above the median?

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/

### myplot.py

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.clf()`
`    pyplot.plot(xs, ps)`
`    myplot.Plot('expo_cdf',`
`              title='Exponential CDF',`
`              xlabel='x',`
`              ylabel='CDF',`
`              legend=False)`

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.