Thursday, August 7, 2025

Calculating the 25th and 75th percentile

To calculate the 25th and 75th percentiles (also known as the first and third quartiles) of a dataset:

  • Sort the data in ascending order.
  • Find the position of the desired percentile using the formula:
    • For the pth percentile:  Position = (n + 1) \times \frac{p}{100} 
    • Where  n  is the number of data points, and  p  is the percentile (25 for 25th, 75 for 75th).
  • Interpret the position:
    • If it's an integer, the value at that position is the percentile.
    • If not, interpolate between the closest ranks.

Example:
For the data set (n = 6):

25th percentile (Q1):

  • Position = (6 + 1) × 0.25 = 1.75
  • Interpolate between 1st (4) and 2nd (8) value:
  •  4 + 0.75 \times (8 - 4) = 7 

75th percentile (Q3):

  • Position = (6 + 1) × 0.75 = 5.25
  • Interpolate between 5th (23) and 6th (42) value:
  •  23 + 0.25 \times (42 - 23) = 27.75 

Summary:

  • 25th percentile: 7
  • 75th percentile: 27.75

These steps work for any dataset. For large data, statistical software (like Excel, Python, or R) can calculate percentiles directly. Let me know if you need the calculation for your specific data.

Example 1

Data: 3, 9, 15, 21, 27, 33, 39 (n = 7)

1. Sort Data: Already sorted.

25th Percentile (Q1):

  • Position = (7 + 1) × 0.25 = 2
  • Q1 is the 2nd value: 9

75th Percentile (Q3):

  • Position = (7 + 1) × 0.75 = 6
  • Q3 is the 6th value: 33

Example 2

Data: 2, 4, 7, 10, 12, 16, 18, 21, 23, 25 (n = 10)

1. Sort Data: Already sorted.

25th Percentile (Q1):

  • Position = (10 + 1) × 0.25 = 2.75
  • Between 2nd (4) and 3rd (7) values:
  • 4 + 0.75 × (7 - 4) = 4 + 0.75 × 3 = 4 + 2.25 = 6.25

75th Percentile (Q3):

  • Position = (10 + 1) × 0.75 = 8.25
  • Between 8th (21) and 9th (23) values:
  • 21 + 0.25 × (23 - 21) = 21 + 0.25 × 2 = 21 + 0.5 = 21.5

Example 3

Data: 5, 8, 12, 20 (n = 4)

1. Sort Data: Already sorted.

25th Percentile (Q1):

  • Position = (4 + 1) × 0.25 = 1.25
  • Between 1st (5) and 2nd (8):
  • 5 + 0.25 × (8 - 5) = 5 + 0.75 = 5.75

75th Percentile (Q3):

  • Position = (4 + 1) × 0.75 = 3.75
  • Between 3rd (12) and 4th (20):
  • 12 + 0.75 × (20 - 12) = 12 + 6 = 18

No comments: