Statistics for
Data Science 1
Describing numerical data: frequency tables, histograms, mean, median, mode, spread and percentiles.
Chapters
- 01Frequency Tables for Numerical DataLecture 3.1
- 02HistogramsLecture 3.1
- 03Stem-and-Leaf DiagramsLecture 3.1
- 04MeanLecture 3.2
- 05MedianLecture 3.3
- 06ModeLecture 3.3
- 07Measures of Dispersion and RangeLecture 3.4
- 08Variance and Standard DeviationLecture 3.4
- 09PercentilesLecture 3.5
- 10Quartiles, Five-Number Summary and IQRLecture 3.5
- 11Week 3 Summary SheetAll lectures
Based on lectures by Usha Mohan, IIT Madras
Frequency Tables for Numerical Data
To describe numerical data we first group the observations into classes (also called categories or bins) and then treat the classes as the distinct values of qualitative data. Once the data are grouped, the frequency and relative-frequency tables are built exactly as in Week 2.
1.1Where Week 3 starts
The lecture begins with a review of Weeks 1 and 2, and then splits variables by type. Weeks 1 and 2 dealt with categorical variables; this week is about numerical ones.
- Descriptive and inferential statistics; sample and population.
- Variables and cases; categorical or numerical; cross-sectional or time-series.
- Measurement scales: nominal, ordinal, interval, ratio.
- Frequency tables, relative frequency, pie and bar charts, mode and median.
- Frequency tables and graphical summaries (histograms, stem-and-leaf).
- Numerical summaries: mean, median, mode.
- Dispersion: range, variance, standard deviation.
- Percentiles and the interquartile range.
1.2Organising numerical data
Raw numbers are hard to read. We group them into classes, and then every class plays the role that a category played in Week 2.
1.3Discrete data: single-value classes
If the data set contains only a relatively small number of distinct values, it is convenient to represent it in a frequency table. Each class represents a distinct value (a single value) along with its frequency of occurrence.
Lecture example: number of people in a household
The responses of 15 individuals to the number of people in their household: 2, 1, 3, 4, 5, 2, 3, 3, 3, 4, 4, 1, 2, 3, 4
- List the distinct values: 1, 2, 3, 4 and 5.
- Tally each response in the row of its value.
- Count the tallies and divide each frequency by the total, 15.
| Value | Tally | Frequency | Relative frequency |
|---|---|---|---|
| 1 | || | 2 | 2 ÷ 15 = 0.133 |
| 2 | ||| | 3 | 3 ÷ 15 = 0.2 |
| 3 | 5 | 5 ÷ 15 = 0.333 | |
| 4 | |||| | 4 | 4 ÷ 15 = 0.267 |
| 5 | | | 1 | 1 ÷ 15 = 0.067 |
| Total | 15 | 1 |
Check: and the relative frequencies add to 1 (to three decimals: ).
The lecture shows an empty grid for this table; the graph of the frequencies is a bar graph over the five values. The tallest bar is at 3, so a household of three people is the most common answer.
1.4Continuous data: class intervals
For continuous data (or discrete data with many distinct values) the values are organised into class intervals, so that the table becomes understandable. A few guidelines have to be followed.
- The smallest value that could go in a class.
- The largest value that could go in a class.
- The difference between the lower limit of a class and the lower limit of the next-higher class.
- The average of the two class limits of a class (its mid point).
The filled dot at 50 means 50 is included; the open dot at 60 means 60 is not. The lower limit is 50, the next class starts at 60, so the width is 10, and the class mark is the midpoint, 55. With the left-end rule, 60 itself belongs to the next class, so the class holds values from 50 up to just below 60.
Guidelines for forming classes
- Number of classes. The appropriate number is a subjective choice; the rule of thumb is to have between 5 and 20 classes.
- No overlaps, no gaps. Each observation should belong to some class and no observation should belong to more than one class.
- Equal lengths. It is common, although not essential, to choose class intervals of equal length.
1.5Lecture example: marks of 50 students
The marks of 50 students in a course are listed below. Group them into class intervals of width 10 and build the frequency and relative-frequency table.
68, 79, 38, 68, 35, 70, 61, 47, 58, 66, 60, 45, 61, 60, 59, 45,39, 80, 59, 62, 49, 76, 54, 60, 53, 55, 62, 58, 67, 55, 86, 56,63, 64, 67, 50, 51, 78, 56, 62, 57, 69, 58, 52, 42, 66, 42, 56, 58
- The smallest mark is 35 and the largest 86, so the classes 30-40, 40-50, 50-60, 60-70, 70-80, 80-90 (six classes, width 10) cover everything. The left-end rule decides the boundary values.
- Put each mark in its class and tally.
- Count and divide by 50.
| Class interval | Frequency | Relative frequency |
|---|---|---|
| 30-40 | 3 | 3 ÷ 50 = 0.06 |
| 40-50 | 6 | 6 ÷ 50 = 0.12 |
| 50-60 | 18 | 18 ÷ 50 = 0.36 |
| 60-70 | 17 | 17 ÷ 50 = 0.34 |
| 70-80 | 4 | 4 ÷ 50 = 0.08 |
| 80-90 | 2 | 2 ÷ 50 = 0.04 |
| Total | 50 | 1 |
Check: and .
1.6Going deeper: choosing the classes
- Start from the extremes. Find the smallest and largest value; the classes must cover both. Here 35 and 86 sit inside 30-90.
- A handy width. A common way to pick the width is (largest - smallest) ÷ (number of classes wanted), rounded up to a convenient number like 5 or 10. Here (86 - 35) ÷ 6 = 8.5, rounded up to 10. This is a practical tip, not a rule from the lecture.
- Why the left-end rule matters. Without it a mark such as 60 could be counted twice (in 50-60 and in 60-70). The rule gives every mark exactly one class.
- Grouping loses detail. Once marks are put in a class we only know the class, not the exact mark. That is why the mean from a grouped table (Chapter 4) is only approximate.
- Decide first: discrete (count, few values) or continuous (measurement, class intervals).
- Always write the total row and check it equals the number of observations (and the relative frequencies add to 1).
- For a boundary value, the class that starts at it wins: 60 goes to 60-70.
- Putting 60 in the class 50-60.
- Using classes that overlap or leave gaps.
- Calling a count a continuous variable (number of siblings is discrete).
- Forgetting that class mark = (lower + upper) ÷ 2.
Histograms
A histogram is the graph of a frequency (or relative-frequency) table of grouped numerical data: one vertical bar per class, with the classes placed on a number line.
2.1Steps to construct a histogram
- Frequency distribution. Obtain a frequency (relative-frequency) distribution of the data.
- Axes. Draw a horizontal axis on which to place the classes and a vertical axis on which to display the frequencies (relative frequencies).
- Bars. For each class, construct a vertical bar whose height equals the frequency (relative frequency) of that class.
- Labels. Label the bars with the classes, the horizontal axis with the name of the variable, and the vertical axis with “Frequency” (“Relative frequency”).
2.2Lecture example: histogram of the 50 marks
Use the frequency table from Chapter 1.
| Class interval | Frequency |
|---|---|
| 30-40 | 3 |
| 40-50 | 6 |
| 50-60 | 18 |
| 60-70 | 17 |
| 70-80 | 4 |
| 80-90 | 2 |
The lecture gives axes with the horizontal scale 30 to 100 and the vertical scale 1 to 18, ready for the bars. Draw a bar over each class with height 3, 6, 18, 17, 4, 2.
Each bar sits over its class on the number line, so neighbouring bars meet at the class boundaries (40, 50, 60, ...). The tallest bars are over 50-60 and 60-70, so most marks are in the fifties and sixties; very few marks are above 70.
2.3Histogram versus bar chart
| Bar chart (Week 2) | Histogram (Week 3) | |
|---|---|---|
| Data | Categorical | Numerical, grouped into classes |
| Horizontal axis | Separate categories | A number line with class intervals |
| Bars | Separated by gaps | Touch at the class boundaries |
| Bar height | Frequency (or relative frequency) | Frequency (or relative frequency) |
2.4Going deeper: relative-frequency histogram and shape
If the bar heights are the relative frequencies instead of the frequencies, the shape is exactly the same, only the vertical scale changes. This is the same idea as in Week 2: relative frequencies let us compare data sets of different sizes.
- Where is the peak? The tallest bars show where most observations lie. Here, between 50 and 70.
- How spread out? The bars run from 30 to 90, so the marks are spread over about 60 points.
- Different class widths change the picture. Very narrow classes give a jagged histogram; very wide classes hide the pattern. That is why the 5 to 20 classes rule of thumb exists.
- Label both axes: the variable under the bars, “Frequency” or “Relative frequency” on the vertical axis.
- To read the number of observations in several classes, add the bar heights.
- If the bars are relative frequencies, multiply by n to get back the frequency.
- Leaving gaps between the bars of a histogram (that is a bar chart).
- Using a different width for one class without noticing.
- Putting counts on the vertical axis but labelling it “Relative frequency”.
Stem-and-Leaf Diagrams
For example, if the data are all two-digit numbers, we can let the stem of a value be the tens digit and the leaf be the ones digit.
- Stem 7, leaf 5.
7 | 5means 75
- Same stem, so the leaves share a row.
7 | 5 8means 75 and 78
3.1Steps to construct a stemplot
- Split. Think of each observation as a stem (all but the rightmost digit) and a leaf (the rightmost digit).
- Stems. Write the stems from smallest to largest in a vertical column to the left of a vertical rule.
- Leaves. Write each leaf to the right of the vertical rule in the row that contains the appropriate stem.
- Sort. Arrange the leaves in each row in ascending order.
3.2Lecture example: ages of 11 patients
The ages, to the nearest year, of 11 patients admitted in a hospital are given. Draw a stem-and-leaf plot for this data set. 15, 22, 29, 36, 31, 23, 45, 10, 25, 28, 48
- Split each age: 15 = stem 1, leaf 5; 22 = stem 2, leaf 2; 29 = stem 2, leaf 9; and so on.
- The stems run from 1 (ages 10 to 19) to 4 (ages 40 to 49): 1, 2, 3, 4.
- Write the leaves in the order the data are given.
- Arrange the leaves in each row in ascending order.
Step 3: leaves in data order
| Stem | Leaf |
|---|---|
| 1 | 5 0 |
| 2 | 2 9 3 5 8 |
| 3 | 6 1 |
| 4 | 5 8 |
2 | 2 means 22
Step 4: leaves sorted
| Stem | Leaf |
|---|---|
| 1 | 0 5 |
| 2 | 2 3 5 8 9 |
| 3 | 1 6 |
| 4 | 5 8 |
2 | 2 means 22; 4 | 8 means 48
Check: the number of leaves is , the number of patients.
Each row is an age decade. Row 2 has five leaves, so five of the eleven patients are in their twenties. Rotated sideways, the rows look like the bars of a histogram, but every individual value is still readable.
3.3Going deeper: stemplot versus histogram
- Keeps the data. A histogram shows only how many values fall in a class; a stemplot also keeps every value. From the plot above you can still read the oldest patient (48) and the youngest (10).
- Sorted for free. With the leaves in order, the data are already sorted, which makes the median (Chapter 5) and percentiles (Chapter 9) easy to find.
- Always give the key. Write “2 | 2 means 22” so the reader knows what the stem and leaf stand for.
- Three-digit data. For 135, the stem is 13 (all but the rightmost digit) and the leaf is 5.
- Count the leaves at the end: the total must equal the number of observations.
- Include stems that have no leaves if they fall inside the range (they show a gap in the data).
- Leaving the leaves unsorted (Step 4).
- Writing the leaf as a two-digit number; a leaf is a single digit.
- Forgetting the key.
Mean
- Where is the centre?
- Measures that indicate the most typical value or centre of a data set: mean, median, mode.
- How spread out?
- Measures that indicate the variability or spread of a data set: range, variance, standard deviation, interquartile range.
The objective is to develop descriptive measures: quantities whose values are determined by the data, used to summarise a data set. We start with the most common one, the mean.
4.1Lecture examples: the mean of small data sets
Example 1. Find the mean of 2, 12, 5, 7, 6, 7, 3.
Example 2: one large value changes the mean. Find the mean of (a) 2, 105, 5, 7, 6, 7, 3 and (b) 2, 105, 5, 7, 6, 3.
Data 1 has its mean at 6, in the middle of the dots. Replacing 12 by 105 pulls the mean to 19.29, a place where no observation lies. Dropping a 7 as well (Data 3) moves it to 21.33. The mean uses every value, so one extreme value moves it a lot.
Example 3: marks of ten students. Find the sample mean of 68, 79, 38, 68, 35, 70, 61, 47, 58, 66
4.2Mean for grouped data
Discrete single-value data. If the value occurs times, the sum of the data is , so
Example 4: household sizes. Find the mean number of people in a household for the 15 responses from Chapter 1.
| Value x | Frequency f | f × x |
|---|---|---|
| 1 | 2 | 2 |
| 2 | 3 | 6 |
| 3 | 5 | 15 |
| 4 | 4 | 16 |
| 5 | 1 | 5 |
| Total | 15 | 44 |
Continuous data. Every observation in a class is replaced by the mid point of the class, so
Example 5: marks of 50 students (grouped continuous data). Find the mean using the grouped table of Chapter 1.
| Class interval | Frequency f | Mid point m | f × m |
|---|---|---|---|
| 30-40 | 3 | 35 | 105 |
| 40-50 | 6 | 45 | 270 |
| 50-60 | 18 | 55 | 990 |
| 60-70 | 17 | 65 | 1105 |
| 70-80 | 4 | 75 | 300 |
| 80-90 | 2 | 85 | 170 |
| Total | 50 | 2940 |
4.3Manipulating the data
Example 6: adding 5 marks. The ten marks above have mean 59. The teacher adds 5 marks to every student. New data: 73, 84, 43, 73, 40, 75, 66, 52, 63, 71.
The mean moves up by exactly 5.
Example 7: scaling down by 40%. The teacher instead multiplies each mark by 0.4. New data: 27.2, 31.6, 15.2, 27.2, 14, 28, 24.4, 18.8, 23.2, 26.4.
The mean is multiplied by 0.4.
4.4Going deeper
- The mean is the balance point. Imagine the dots as equal weights on a ruler: the mean is where the ruler balances. That is why one far-away value drags it.
- Deviations add to zero. The deviations always add to 0 (you will see this in Chapter 8 for the ten marks).
- The mean need not be a data value. The mean household size is 2.93 people, and no household has 2.93 people.
- Both rules together. If every value becomes , the mean becomes . Apply the multiplication and the addition one after the other.
- Grouped mean is only approximate. The exact mean needs the original marks; the grouped table only knows the class of each mark.
- Total first, then divide: write the sum and the count separately.
- For grouped data build the extra column (f × x or f × m) and add it up.
- The divisor in the grouped formulas is the total frequency n, not the number of rows.
- Dividing by the number of classes instead of the total frequency.
- Using the class limits instead of the mid points.
- Forgetting that the mean is pulled by outliers.
Median
5.1Steps to obtain the median
Arrange the data in increasing order. Let be the total number of observations.
The median is the observation exactly in the middle of the ordered list:
The median is the mean of the two middle observations:
5.2Lecture examples
Example 1: odd number of observations. Find the median of 2, 12, 5, 7, 6, 7, 3.
- Arrange in increasing order: 2, 3, 5, 6, 7, 7, 12.
- is odd, so the median is the th observation, which is 6.
Example 2: odd n with a large value. Find the median of 2, 105, 5, 7, 6, 7, 3.
- Ordered: 2, 3, 5, 6, 7, 7, 105.
- is odd, the 4th observation is 6, the same as before even though 12 became 105.
Example 3: even number of observations. Find the median of 2, 105, 5, 7, 6, 3.
- Ordered: 2, 3, 5, 6, 7, 105.
- is even, so take the average of the 3rd and 4th observations: 5.5.
5.3Mean versus median: outliers
Example 4: sensitivity to outliers. Compare the mean and median of (1) 2, 12, 5, 7, 6, 7, 3 and (2) 2, 117, 5, 7, 6, 7, 3.
5.4Manipulating the data
Example 5: adding 5 marks. Marks: 68, 79, 38, 68, 35, 70, 61, 47, 58, 66. Find the median, then the median after adding 5 to each mark.
- Ascending: 35, 38, 47, 58, 61, 66, 68, 68, 70, 79. is even, so the median is the average of the 5th and 6th: 63.5.
- After adding 5, ascending: 40, 43, 52, 63, 66, 71, 73, 73, 75, 84. Median 68.5 .
Example 6: scaling down by 40%. The marks are multiplied by 0.4. Find the new median.
- New data ascending: 14, 15.2, 18.8, 23.2, 24.4, 26.4, 27.2, 27.2, 28, 31.6.
- The 5th and 6th values are 24.4 and 26.4, so the median is 25.4 .
5.5Going deeper
- Sort first. The median only makes sense on the ordered list. If the data are in a stem-and-leaf plot with sorted leaves, they are already sorted.
- Positions, not values. is a position. For it is 4, so look at the 4th value. For it is 5.5, meaning halfway between the 5th and 6th values.
- When to prefer the median. When a few extreme values would drag the mean (incomes, house prices), the median describes the typical case better.
- The median is the 50th percentile. Chapter 9 puts this in a bigger picture.
- Both rules together. If every value becomes , the median becomes .
- Write the ordered list out before picking the middle.
- Check odd or even before choosing the rule.
- With ties (like 7, 7) keep both in the list.
- Taking the middle of the unsorted list.
- For even n, taking only one of the middle values.
- Dropping repeated values when sorting.
Mode
6.1Steps to obtain the mode
- If no value occurs more than once, then the data set has no mode.
- Else, the value that occurs with the greatest frequency is a mode of the data set.
6.2Lecture examples
Example 1: mode of three data sets.
| Data set | Values | Mode |
|---|---|---|
| (1) | 2, 12, 5, 7, 6, 7, 3 | 7 occurs twice and every other value once: 7 |
| (2) | 2, 105, 5, 7, 6, 7, 3 | Replacing 12 by 105 does not change it: 7 |
| (3) | 2, 105, 5, 7, 6, 3 | No value occurs more than once: no mode |
6.3Manipulating the data
Example 2: adding 5 marks. Marks: 68, 79, 38, 68, 35, 70, 61, 47, 58, 66. The mode is 68 (it occurs twice). Find the mode after adding 5 marks to each.
The data are 40, 43, 52, 63, 66, 71, 73, 73, 75, 84. The value 73 occurs twice, so the mode is 73 .
Example 3: scaling down by 40%. Find the mode after multiplying each mark by 0.4.
The data are 27.2, 31.6, 15.2, 27.2, 14, 28, 24.4, 18.8, 23.2, 26.4. The value 27.2 occurs twice, so the mode is 27.2 .
6.4Going deeper
- Mode can be missing or repeated. No value repeated: no mode. Two values tied for the top: two modes (bimodal), as in Week 2.
- From a frequency table: the mode is the value with the largest frequency. For grouped continuous data we speak of the modal class, the class with the tallest histogram bar (here 50-60 in the marks table). This is an extension, not a slide from the lecture.
- Compare the three centres. Mean uses every value (sensitive to outliers), median uses the middle position (not sensitive), mode uses only the counts (works even for categories).
- The mode is a data value. Unlike the mean (2.93 people), the mode always is one of the observations.
- Tally the values; the biggest tally is the mode.
- Always say “no mode” when every value occurs once.
- Giving the frequency of the mode instead of the mode itself.
- Writing 0 for “no mode”.
Measures of Dispersion and Range
Two data sets can have the same centre and still be different. Compare dataset 1: 3, 3, 3, 3, 3 and dataset 2: 1, 2, 3, 4, 5.
| Dataset 1 | Dataset 2 | |
|---|---|---|
| Mean | 3 | 3 |
| Median | 3 | 3 |
| Mode | 3 | Not available |
Every dot of dataset 1 sits at 3 (the five dots are stacked), while dataset 2 spreads from 1 to 5. The mean and median (the triangles) are identical, so they cannot tell the data sets apart. We need a measure of the amount of variation, or spread.
7.1Range
Example 1: range of the two data sets.
| Dataset 1 (3, 3, 3, 3, 3) | Dataset 2 (1, 2, 3, 4, 5) | |
|---|---|---|
| Max | 3 | 5 |
| Min | 3 | 1 |
| Range | 3 - 3 = 0 | 5 - 1 = 4 |
The range separates the two data sets, which the mean and median could not.
7.2Range is sensitive to outliers
Example 2: one value changes the range. Compare dataset 1 (1, 2, 3, 4, 5) and dataset 2 (1, 2, 3, 4, 15).
| Dataset 1 | Dataset 2 | |
|---|---|---|
| Max | 5 | 15 |
| Min | 1 | 1 |
| Range | 4 | 14 |
The two datasets differ in only one data point, yet the range jumps from 4 to 14. This happens because the range takes into consideration only the Min and the Max of the data.
7.3Going deeper
- Range uses two observations. The values in between can be anything; the range does not see them. Chapter 8 introduces measures that use every observation.
- Range zero means no variation. Range 0 happens exactly when all the values are equal.
- Units. The range is in the same units as the data (marks, kilograms, years).
- Adding a constant to every value moves Max and Min by the same amount, so the range is unchanged. The lecture does not cover this, but it follows from the definition.
- Range = Max - Min, always non-negative.
- Use the range for a quick feel, but not when outliers are possible.
- Subtracting in the wrong order and getting a negative range.
- Thinking equal means and medians imply equal spread.
Variance and Standard Deviation
In contrast to the range, the variance takes into account all the observations. One way of measuring the variability of a data set is to consider the deviations of the data values from a central value, the mean.
- The numerator is the sum of squared deviations of every observation from its mean.
- The denominator for the population variance is , the total number of observations.
- The denominator for the sample variance is . The reason will be clear in forthcoming courses on statistics.
8.1Lecture example: marks of ten students
The marks of ten students are given and the mean is 59. Find the population variance and the sample variance. 68, 79, 38, 68, 35, 70, 61, 47, 58, 66
Step 1. Subtract the mean from each mark (the deviation) and square it.
| # | Data x | Deviation x - 59 | Squared deviation |
|---|---|---|---|
| 1 | 68 | 9 | 81 |
| 2 | 79 | 20 | 400 |
| 3 | 38 | -21 | 441 |
| 4 | 68 | 9 | 81 |
| 5 | 35 | -24 | 576 |
| 6 | 70 | 11 | 121 |
| 7 | 61 | 2 | 4 |
| 8 | 47 | -12 | 144 |
| 9 | 58 | -1 | 1 |
| 10 | 66 | 7 | 49 |
| Total | 590 | 0 | 1898 |
The labels on the axis are the marks. Bars above the axis are marks above the mean 59; bars below are marks below it. Positive and negative deviations cancel, so the plain sum is 0 and tells us nothing. Squaring makes every term non-negative.
Step 2. Sum of squared deviations = 1898.
Step 3. Divide:
8.2Standard deviation
Example: standard deviation of the marks.
8.3Manipulating the data
The standard deviation is also unchanged.
The standard deviation is multiplied by .
Example: adding 5 marks. New data: 73, 84, 43, 73, 40, 75, 66, 52, 63, 71. Every deviation from the new mean (64) is the same as before, so the sum of squared deviations is still 1898.
In general, adding a constant does not change the variability of a data set.
Example: scaling down by 40%. New data: 27.2, 31.6, 15.2, 27.2, 14, 28, 24.4, 18.8, 23.2, 26.4 with mean 23.6. Sum of squared deviations = 303.68.
Check: . For the standard deviation: .
8.4Going deeper
- Why square? The plain deviations add to 0. Squaring removes the signs, and it also punishes big deviations more than small ones.
- Why a standard deviation too? The variance is in square units (marks2); taking the square root brings it back to marks, so it can be compared directly with the data.
- Sample versus population. Divide by when you have the whole population, by when you have a sample. For the ten marks: 189.8 (population) and 210.89 (sample).
- A shortcut for calculation. The sum of squared deviations also equals . For the ten marks: . This is an extra, not part of the lecture.
- Zero variance. Variance is 0 only when every value equals the mean (like 3, 3, 3, 3, 3).
- Negative multiplier. The variance is multiplied by , which is never negative; the standard deviation is multiplied by . The lecture uses positive .
- Build the deviation table: x, x - mean, (x - mean)2, and check that the deviations add to 0.
- Read the question: “variance” alone usually means the sample variance (divide by n - 1) unless the data are called a population.
- Standard deviation is the square root of the variance, never the other way round.
- Dividing by n for a sample (use n - 1).
- Squaring after adding the deviations instead of before.
- Multiplying the variance by c instead of c2.
- Reporting the variance in the units of the data (it is in square units).
Percentiles
9.1Computing a percentile: the n p rule
To find the sample 100p percentile of a data set of size :
- Arrange the data in increasing order.
- If is not an integer, find the smallest integer greater than . The data value in that position is the sample 100p percentile.
- If is an integer, the average of the values in positions and is the sample 100p percentile.
9.2Lecture example: percentiles of the ten marks
Let . Arrange the marks in ascending order: 35, 38, 47, 58, 61, 66, 68, 68, 70, 79. Find the 10th, 25th, 50th, 75th and 100th percentiles.
| p | np | Rule | Percentile |
|---|---|---|---|
| 0.1 | 1 | integer: average of positions 1 and 2 | (35 + 38)/2 = 36.5 |
| 0.25 | 2.5 | not an integer: next integer is 3, so position 3 | 47 |
| 0.5 | 5 | integer: average of positions 5 and 6 | (61 + 66)/2 = 63.5 |
| 0.75 | 7.5 | not an integer: next integer is 8, so position 8 | 68 |
| 1 | 10 | integer (there is no position 11) | 79 (the maximum) |
9.3Percentiles in Google Sheets
For example, if the data are in cells A1:A10 and we want the 90th percentile, enter PERCENTILE(A1:A10,0.9) in a blank cell.
- Paste the data set in a column.
- In a blank cell enter
PERCENTILE(data, percentile), wheredatais the range of the data andpercentileis the decimal form of the desired percentile.
The algorithm Google Sheets uses
- Arrange the data in increasing order and write for the i-th ordered value.
- Find the rank:
- Split the rank into its integer part and fractional part.
- Find the ordered value for the integer part.
- Percentile .
Example: the 25th percentile by the rank method. For the ten ordered marks 35, 38, 47, 58, 61, 66, 68, 68, 70, 79, find the 25th percentile.
- : integer part 3, fractional part 0.25.
- , .
- .
| Percentile | n p rule | Google Sheets rank method |
|---|---|---|
| 10th | 36.5 | rank : 37.7 |
| 25th | 47 | 49.75 |
| 50th | 63.5 | 63.5 |
| 75th | 68 | 68 |
The 10th percentile row is worked out here from the same two rules; the lecture states only the 25th percentile difference. Always use the method the question names.
9.4Going deeper
- Percentile means position, not marks. Being at the 75th percentile means that about 75% of the data are at or below your value.
- Why two methods? With small data sets there is no value that cuts exactly 25% off, so different rules choose differently. For large data sets the answers are almost the same.
- Sorted data first. Both methods need the ordered list. A sorted stemplot gives it for free.
- The median is a special case. For the n p rule is exactly the median rule of Chapter 5 ().
- Write first; integer or not decides the rule.
- Positions start from 1 (the smallest value is position 1).
- In the rank method, is the gap you travel the fractional part along.
- Using an unsorted list.
- Rounding to the nearest integer instead of the next integer.
- Mixing the two methods in one question.
Quartiles, Five-Number Summary and IQR
In other words, the quartiles break up a data set into four parts, with about 25 percent of the data values being less than the first (lower) quartile, about 25 percent between the first and second quartiles, about 25 percent between the second and third (upper) quartiles, and about 25 percent larger than the third quartile.
10.1The five-number summary
- Minimum: the smallest value.
- First quartile: the lower quartile.
- Second quartile: the median.
- Third quartile: the upper quartile.
- Maximum: the largest value.
10.2The interquartile range
Lecture example: IQR of the ten marks. For the ten marks (ordered: 35, 38, 47, 58, 61, 66, 68, 68, 70, 79) find the interquartile range.
- First quartile (25th percentile): .
- Third quartile (75th percentile): .
The five-number summary of these marks is Min = 35, Q1 = 49.75, Q2 = 63.5, Q3 = 68, Max = 79.
The five circles are the five numbers on the number line. The bracket from Q1 to Q3 is the IQR, 18.25: it measures the spread of the middle part of the data, between the 25th and 75th percentiles.
10.3Going deeper
- IQR versus range. The range of the ten marks is ; the IQR is 18.25. The IQR looks only at the middle half, so one extreme value cannot stretch it the way it stretches the range.
- The middle 50%. About half of the data lie between Q1 and Q3, and the IQR is the width of that stretch.
- Which method for Q1 and Q3? The lecture example uses the Google Sheets values. With the n p rule the same data would give Q1 = 47 and so IQR = 68 - 47 = 21. Use the method the question names.
- Centre and spread together. Median with IQR is a good pair for skewed data; mean with standard deviation is the other usual pair.
- Write the five numbers in order: Min, Q1, Q2, Q3, Max.
- IQR is one number (Q3 - Q1), not an interval.
- Calling Q2 the mean (it is the median).
- Subtracting Max - Min and calling it the IQR.
Week 3 Summary Sheet
Everything in Week 3 on one sheet, for a last-minute revision.
Effect of a constant on each measure
| Measure | Add c to every value | Multiply every value by c | Marks example (+5 / × 0.4) |
|---|---|---|---|
| Mean | mean + c | mean × c | 59 → 64 / 23.6 |
| Median | median + c | median × c | 63.5 → 68.5 / 25.4 |
| Mode | mode + c | mode × c | 68 → 73 / 27.2 |
| Variance | unchanged | c² × variance | 210.89 → 210.89 / 33.74 |
| Standard deviation | unchanged | c × standard deviation | 14.522 → 14.522 / 5.808 |
The lecture shows the effect of constants on the mean, median, mode, variance and standard deviation. It does not cover range or IQR, so they are not in the table.
Formulas
Grouped: replace the sum by (discrete) or (class mid points).
Population variance divides by .
Median position: .
Which graph or table for which data
| Data | Table | Graph |
|---|---|---|
| Discrete, few distinct values | Frequency table with single values | Bar graph of frequencies |
| Continuous | Frequency table with class intervals (left end included) | Histogram |
| Any numerical data (values kept) | - | Stem-and-leaf diagram |
Topic by topic
- Discrete: one row per value.
- Continuous: class intervals [low, high).
- Histogram of class frequencies.
- Stem-and-leaf diagram.
- Mean = sum / count.
- Median = middle of the ordered list.
- Mode = most frequent value.
- Range = Max - Min.
- Variance and standard deviation.
- IQR = Q3 - Q1.
- 100p percentile; n p rule.
- Sheets: rank = p(n - 1) + 1.
- Quartiles, five-number summary.
- Add c: centre shifts, spread same.
- Multiply by c: centre × c, variance × c².
Continuous: class intervals [low, high)
Stem-and-leaf diagram
Median = middle of the ordered list
Mode = most frequent value
Variance and standard deviation
IQR = Q3 - Q1
Sheets: rank = p(n - 1) + 1
Quartiles, five-number summary
Multiply by c: centre × c, variance × c²