1. LPU MCA Semester 1
  2. CAB107
  3. Unit 3

CAB107 · Unit 3: Data collection, preprocessing and visualization

Descriptive statistics, correlation and covariance

10 practice questions · in the MTE and ETE syllabus

Key points

  • Correlation is unit-free and bounded between -1 and 1
  • Covariance depends on units and can be any sign
  • Spearman captures monotonic, not only linear, relations
  • Correlation never proves causation

Descriptive statistics summarise data: measures of centre (mean, median, mode), spread (variance, standard deviation, range, IQR) and shape. The median resists outliers; the mean does not.

Covariance measures how two variables vary together; it can be positive, negative or zero and depends on the units. Correlation rescales covariance by the two standard deviations, giving a unit-free value between -1 and +1.

MeasureCapturesRange
PearsonLinear relationship-1 to 1
SpearmanMonotonic relationship, rank-based-1 to 1

Worked example: for x = 1 to 5 and y = x squared, y rises with every increase of x, so Spearman is exactly 1.0, while Pearson is slightly below 1.0 because the relationship is curved.

import pandas as pd
df = pd.DataFrame({'x': [1, 2, 3, 4, 5]})
df['y'] = df['x'] ** 2
print(df.corr(method='spearman'))

Correlation is usually reported instead of covariance because it is unit-free and bounded. A correlation of 0 means no linear relationship, not no relationship at all.

Exam trap: correlation is not causation. Ice cream sales and drowning rise together because hot weather drives both, not because one causes the other.

Try two questions

Question 1 · Tier 2, Understand

Why is correlation usually reported instead of covariance for comparing two relationships?

  1. Covariance can be computed only for text data, so numeric columns need correlation instead
  2. Correlation values are numerically larger than covariance values, so they are easier to read
  3. Correlation is unit-free and bounded, while covariance depends on the units of the variables
  4. Covariance is negative for most real datasets, which makes it unsuitable for describing relationships
Show the answer

C. Correlation is covariance divided by the product of the standard deviations.

Why not A: Covariance is computed on numeric variables.

Why not B: Their sizes depend on the data; there is no universal ordering.

Why not D: Covariance can be positive, negative or zero.

Question 2 · Tier 4, Analyse

Ice cream sales and drowning incidents show a correlation of 0.9 across months. Which interpretation is the most defensible?

  1. Ice cream causes people to drown, so ice cream sales should be banned during the summer months
  2. Drowning incidents cause people to buy more ice cream, so one variable drives the other directly
  3. The data must be wrong, because a correlation as high as 0.9 cannot occur in real monthly data
  4. A common factor such as hot weather probably drives both, so correlation does not show causation
Show the answer

D. A confounder such as temperature can produce a strong correlation between unrelated variables.

Why not A: Correlation alone does not establish that one variable causes the other.

Why not B: A reverse causal link is not supported either.

Why not C: High correlation by a shared cause is common and not evidence of an error.