James Ashton MathsFREE MATHEMATICS. OPEN TO EVERYONE.
HomeIB DiplomaA levelAbout
IB Diploma › Maths AI SL › Statistics & probability › Spearman’s rank

Spearman’s rank correlation

Spearman’s rank correlation coefficient rs measures how well two variables agree in order, not in a straight line. You rank the data (averaging tied ranks), then find the correlation of the ranks on the GDC, and decide whether Spearman or Pearson suits the data better.

SL 4.10Paper 1Paper 2GDC allowed≈ 35 min to work through
Before you start: Pearson’s r on the GDC (Correlation & regression).

1What you need to know

Tick these off as you go. By the end of the page you should be able to do all of them without notes.

  • Rank data, giving tied values the average of their ranksSL 4.10
  • Find rs with the GDC, as Pearson’s r of the ranksSL 4.10
  • Interpret rs: agreement in order (a monotonic relationship)SL 4.10
  • Explain when Spearman is more appropriate than Pearson, including the effect of outliersSL 4.10

2Notes & worked examples

Each idea is followed by a worked example. Try the question yourself first, then reveal the solution one step at a time.

The big idea

Pearson’s r asks: do the points lie close to a straight line? Spearman’s rs asks a simpler question: when one variable goes up, does the other go up too? (a "monotonic" relationship). So rs suits curved but always-increasing data, rankings such as judges’ scores, and data with outliers. Like r, it runs from −1 to +1.

2.1 Ranking

Rank each variable separately: 1 for the largest (or the smallest; just be consistent for both variables). If values are tied, give each the average of the ranks they would take. For example, in 12, 15, 15, 18, 20 (smallest first), the two 15s share ranks 2 and 3, so each gets 2.5: the ranks are 1, 2.5, 2.5, 4, 5.

2.2 Finding rs on the GDC

Worked example 1Paper 1
Two judges score six divers. Judge 1: 8.5, 7.0, 9.1, 6.4, 7.8, 8.0. Judge 2: 8.0, 6.5, 9.4, 7.0, 7.2, 8.8. Find Spearman’s rank correlation coefficient and interpret it.
Ranks (highest = 1). Judge 1: 2, 5, 1, 6, 4, 3. Judge 2: 3, 6, 1, 5, 4, 2.
Write the ranks in a table: it earns a method mark.
Enter the two lists of ranks and find Pearson’s r of them (Linear Regression): rs=0.886
Spearman’s coefficient is just Pearson’s r calculated on the ranks.
Strong positive agreement: the judges largely rank the divers in the same order.
Worked example 2Paper 1
Rank the values 6.2, 7.5, 5.1, 8.3, 7.5, 4.0, 9.1 from smallest to largest.
In order: 4.0, 5.1, 6.2, 7.5, 7.5, 8.3, 9.1
Ranks: 4.0 → 1, 5.1 → 2, 6.2 → 3, 7.5 → 4.5, 7.5 → 4.5, 8.3 → 6, 9.1 → 7
The two 7.5s would take ranks 4 and 5, so each gets 4.5.
In the original order: 3, 4.5, 2, 6, 4.5, 1, 7

2.3 Spearman or Pearson?

SituationBetter choice
Points close to a straight linePearson r
Always increasing (or decreasing), but curvedSpearman rs
Data are ranks or scores from judgesSpearman rs
There is an outlierSpearman rs is less affected
Worked example 3Paper 2
For x=1,2,…,6 and y=2x, find r and rs. Explain the difference.
r=0.906; rs=1
The relationship is perfectly increasing (monotonic), so rs=1. It is curved, not linear, so r<1.
Spearman detects the perfect agreement in order that Pearson misses.
Worked example 4Paper 2
Data: x: 1, 2, 3, 4, 5, 6, 7, 8; y: 3, 4, 6, 5, 7, 8, 9, 30. Find r and rs, and comment.
r=0.743; rs=0.976
The value 30 is an outlier. It pulls Pearson’s r down a lot, but in the ranks it is just "the largest", so rs is hardly affected.
Worked example 5 (faded)Paper 1
Give the ranks (smallest = 1) of 12, 15, 15, 18, 20.
Ranks: 1, 2.5, 2.5, 4, 5  ← you work this out
On your TI-Nspire Calculator tricks →

Type the ranks (not the raw data) into two lists, then menu → Statistics → Stat Calculations → Linear Regression (ax+b); the value r in the output is rs. Ignore a and b: they mean nothing here. Check your ranks before you calculate: a single wrong rank changes the answer.

3Explore it

Move the last point up and down, or switch to curved data. Compare Pearson’s r with Spearman’s rₛ: which one reacts to the outlier, and which one notices that the curved data always increases?

4Common mistakes & exam tips

Common mistakes

  • Calculating r of the raw data instead of the ranks.
  • Ranking one variable from largest and the other from smallest.
  • Giving tied values different ranks, or the wrong average rank.
  • Saying rs=1 means the points lie on a straight line. It means the order agrees perfectly.
  • Choosing Pearson for data with a clear outlier or a curved but monotonic pattern.

Exam tips

  • Show your ranks in a table before using the GDC.
  • "Which coefficient is more appropriate?" Look at the scatter diagram: curved, outliers or ranked data point to Spearman.
  • Interpret rs in context: "the two judges rank the divers in a very similar order".
  • If a question asks for the effect of an outlier, say that rs is less sensitive because it uses ranks only.

5Practice

Fluency questions build the basics. Problem-solving questions make you think about which method to use.

FluencyP1
Rank 40, 35, 50, 35, 60 from largest (rank 1).
60 → 1, 50 → 2, 40 → 3, 35 → 4.5, 35 → 4.5
FluencyP2
Two variables have ranks x: 1, 2, 3, 4, 5 and y: 2, 1, 4, 3, 5. Find rs.
rs=0.8
FluencyP3
What does rs=−1 tell you?
As one variable increases, the other always decreases: the orders are exactly reversed.
FluencyP4
Why can rs=1 when r<1?
The data always increases (monotonic) but is not on a straight line.
Problem solvingP5
Price (€): 25, 40, 32, 55, 18, 47; customer rating: 3, 6, 5, 8, 4, 7. Find rs and interpret it.
rs=0.943: strong agreement: more expensive products tend to be rated higher.
Problem solvingP6
A data set has one extreme value. Explain why rs changes less than r when it is removed.
In ranks, the extreme value is just the largest rank; its size does not matter.

6Exam-style questions

Original questions in the style of the IB Maths AI SL exam, with full markschemes. Your GDC is allowed throughout: use it, but write down what you entered and what it gave you. Give yourself about 1 minute per mark.

Question 1Paper 1[6 marks]

The hours of sunshine h and the number of ice creams sold n on seven days are: h: 6.2, 7.5, 5.1, 8.3, 7.5, 4.0, 9.1; n: 110, 150, 95, 170, 140, 80, 160.

  • (a)Write down the ranks of h, from smallest to largest.[2]
  • (b)Find Spearman’s rank correlation coefficient, rs.[2]
  • (c)Interpret your answer in context.[2]
(a)
3, 4.5, 2, 6, 4.5, 1, 7A2
Award A1 for correct ranks without averaging the tie.
(b)
ranks of n: 3, 5, 2, 7, 4, 1, 6(M1)
rs=0.955A1
(c)
strong positive associationA1
sunnier days tend to have more ice creams soldR1
Question 2Paper 1[5 marks]

Data for x=1,2,…,6 follow the rule y=2x.

  • (a)Find Pearson’s r.[1]
  • (b)Write down Spearman’s rs. Justify your answer.[2]
  • (c)State which coefficient better describes the relationship, giving a reason.[2]
(a)
r=0.906A1
(b)
rs=1A1
y increases every time x increases, so the ranks agree exactlyR1
(c)
SpearmanA1
the relationship is monotonic but not linearR1
Question 3Paper 2[6 marks]

For eight students, x is the hours of revision and y the test mark: x: 1, 2, 3, 4, 5, 6, 7, 8; y: 3, 4, 6, 5, 7, 8, 9, 30.

  • (a)Find Pearson’s r and Spearman’s rs.[2]
  • (b)Identify the value that affects r most, and explain why it has little effect on rs.[2]
  • (c)State, with a reason, which coefficient is more appropriate here.[2]
(a)
r=0.743A1
rs=0.976A1
(b)
y=30 (the outlier)A1
its rank is simply 8, the highest, whatever its sizeR1
(c)
SpearmanA1
it is less affected by the outlierR1

7Check yourself

Six quick questions, marked instantly. Aim for 6/6 before moving on. Fractions like 3/2 are accepted.

8Past-paper practice

Once you're scoring well above, try these real IB Maths AI SL questions. Your school or teacher will have the papers.

PaperQuestionFocusDifficulty
May 2025 · TZ2 · Paper 1Q10Two judges ranking sheepdogs: rₛ and agreement★★☆
May 2023 · TZ1 · Paper 1Q1Decathlon long and high jump: rank, rₛ, interpret★★☆
May 2023 · TZ2 · Paper 1Q4Age vs 100 m time: ranks, rₛ, why not Pearson★★☆
Nov 2024 · TZ1 · Paper 2Q3Survey data: quartiles, outlier, ranks, rₛ, validity★★☆
Spotted a mistake on this page?Tell me and I'll fix it. The button opens an email with this page already named, or write to jamesashtonmaths@gmail.com.
Report a mistake