# Biased Distribution described in “Think Stats”

In the Chapter 3 of Think Stats by Allen Downey book. The following is the excerpt from the book:

First, I compute the distribution as observed by students, where the probability associated with each class size is “biased” by the number of students in the class.

def BiasPmf(pmf, label):
new_pmf = pmf.Copy(label=label)

for x, p in pmf.Items():
new_pmf.Mult(x, x)

new_pmf.Normalize()
return new_pmf


For each class size, x, we multiply the probability by x, the number of students who observe that class size. The result is a new Pmf that represents the biased distribution.

1. What is the meaning of the bias here?
2. Is the author skewing the value by a certain factor and thus, creating an artificial "bias"?

If there's a better forum to discuss questions regarding the book material - please let us know.

This exercise is illustrating that the 'average class size' as calculated by the Dean is not the same as the average class size as experienced by a student. The difference can be viewed this way: the Dean's average is the expected class size when picking a class at random, while the student's average is the expected class size when picking a student at random and asking the size of that student's class. To create a student-centric distribution of class sizes, you need to replicate each class size x as many times as the number of students in the class (again, x). In other words:
for x, p in pmf.Items():