### 2.1. What's an Average?

For some people, average case analysis is difficult because they don't have a very flexible idea of what an "average" is.

Last semester, Professor Cord gave out the following grades in his CS361 class:

A, A, A-, B+, B, B, B, B-, C+, C, C-, D, F, F, F, F

Translating these to their numerical equivalent,

4, 4, 3.7, 3.3, 3, 3, 3, 2.7, 2.3, 2, 1.7, 1, 0, 0, 0, 0

what was the average grade in Cord's class?

According to some classic forms of average:

Median

the middle value of the sorted list, (the midpoint between the two middle values given an even number of items)

avgmedian = 2.5
Mode

the most commonly occurring value

avgmodal = 0
mean

Computed from the sum of the elements

avgmean = (4 + 4 + 3.7 + 3.3 + 3 + 3 + 3 + 2.7 + 2.3 + 2 + 1.7 + 1 + 0 + 0 + 0 + 0) / 16 = 2.11

#### Mean Average

The mean average is the most commonly used, but even that comes in comes in many varieties

Simple mean
\bar{x} = (\sum_{i=1}^N x_i) / N
Weighted mean
\bar{x} = (\sum_{i=1}^N w_i * x_i) / (\sum_{i=1}^N w_i)

Example: Last semester Professor Cord gave the following grades

4.0 2
3.7 1
3.3 1
3.0 3
2.7 1
2.3 1
2.0 1
1.7 1
1.3 0
1.0 1
0.0 4

The weighted average is

(2*4.0 + 1*3.7 + 1*3.3 + 3*3.0 + 1*2.7 + 1*2.3 + 1*2.0 + 1*1.7 + 0*1.3 + 1*1.0 + 4*0.0) / (2 + 1 + 1 + 3 + 1 + 1 + 1 + 1 + 0 + 1 + 4) = 2.11

Example: When one student asked about his grade, Professor Cord pointed out that assignments were worth 50% of the grade, the final exam was worth 30%, and the midterm exam worth 20%. The student has a B, A, and C-, respectively on these.

Category Score Weight
Assignments 3.0 50
Final 4.0 30
Midterm 1.7 20

So the student's average grade was

(50*3.0 + 30*4.0 + 20*1.7)/(50+30+20) = 3.04

#### Expected Value

The expected value is a special version of the weighted mean in which the weights are the probability of seeing each particular value.

If x_1, x_2, \ldots, are all the possible values of some quantity, and these values occur with probability p_1, p_2, \ldots,, then the expected value of that quantity is

E(x) = \sum_{i=1}^N p_i * x_i

Note that if we have listed all possible values, then

\sum_{i=1}^N p_i = 1

so the usual denominator in the definition of the weighted sum becomes simply "1".

Example: after long observation, we have determined that Professor Cord tends to give grades with the following distribution:

4.0 2/16
3.7 1/16
3.3 1/16
3.0 3/16
2.7 1/16
2.3 1/16
2.0 1/16
1.7 1/16
1.3 0/16
1.0 1/16
0.0 4/16

So the expected value of the grade for an average student in his class is

((2/16)*4.0 + (1/16)*3.7 + (1/16)*3.3 + (3/16)*3.0 + (1/16)*2.7 + (1/16)*2.3 + (1/16)*2.0 + (1/16)*1.7 + (0/16)*1.3 + (1/16)*1.0 + (4/16)*0.0) = 2.11

The expected value is the kind of average we will use throughout this course.