TECHNOLOGIESTieInn Technologies

Spread: range, variance, standard deviation, IQR

Statistics · 13 questions

Short notes

Key idea

Two datasets can share an average and still look nothing alike. Spread measures how far values sit from the centre: the range, the variance, the standard deviation and the interquartile range (IQR).

Syntax

x.max() - x.min()            # range
x.var(); x.std()             # pandas uses n - 1 (sample)
q1, q3 = x.quantile([0.25, 0.75]); iqr = q3 - q1
  • Variance = average squared distance from the mean; SD = its square root, in the original units.
  • IQR = spread of the middle 50%.

Example

Delivery days for two couriers, both with mean 4: A = 4, 4, 4, 4; B = 1, 2, 6, 7. A's SD is 0, B's about 2.9. Customers would far rather use A, though the averages match.

Traps

  • The range uses only two values, so one outlier ruins it.
  • SD is pulled by outliers too; use the IQR for skewed data.
  • Sample vs population: pandas std() divides by n − 1, NumPy's np.std by n unless you pass ddof=1.
  • Compare spreads in context: an SD of 5 is large for marks out of 20, tiny for salaries.

Want the full lesson with step-by-step examples, a project and a certificate? Statistics course, ₹120 →

Questions

Open in Code Lab5 free questions
5 questions

    Spread: range, variance, standard deviation, IQR

  1. Question 1easy

    Which measure of spread is least affected by one extreme value?

  2. Spread: range, variance, standard deviation, IQR

  3. Question 2medium

    Why can df["x"].std() and np.std(df["x"]) give different answers?

  4. Spread: range, variance, standard deviation, IQR

  5. Question 3easy

    The cheapest product costs 249 and the most expensive 5999. What does this print?

    print(products["price"].max() - products["price"].min())
  6. Spread: range, variance, standard deviation, IQR

  7. Question 4medium

    What does this print?

    p = products["price"]
    print(p.quantile(0.75) - p.quantile(0.25))
  8. Spread: range, variance, standard deviation, IQR

  9. Question 5easy

    Two shops both have an average order of ₹9,000. What else do you need to know whether they're alike?

8 more questions on this topic, with hints, and tests

Sign up free for 21 days of every question and test.