Descriptive Statistics

  1. Central Tendency

    Question 1 of 2

    • Write a function calc_mean that takes a list of numbers and returns mean.
    • Write a function calc_median that takes a list of numbers and returns median.
    • Write a function calc_mode that takes a list of numbers and returns mode.
    • Test functions with the dataset [2, 1, 2, 5, 100]. Verify mean = 22, median = 2, mode = 2.
    • Write a function calc_percentile that takes a list of numbers and a percentile value (0-100). Returns the corresponding pth percentile value i.e. [p * (n+1) / 100]th item in sorted data.
    • Write a function calc_quartiles that takes a list of numbers and returns Q1, Q2, Q3. Reuse above function for this.
  2. Dispersion

    Question 2 of 2

    • Write a function calc_range that takes a list of numbers and returns range (L -S).
    • Write a function calc_covariance that takes two lists of numbers and returns covariance.
    • Write a function calc_variance that takes a list of numbers and returns variance.
    • Write a function calc_correlation that takes two lists of numbers and return correlation.
    • Test functions with the datasets X = [5, 20, 95] and Y = [10, 30, 50]. Verify range(X) = 90, covariance = 600, variance(X) = 4650, correlation = 0.54.
    • Write a function calc_bmi that takes height (in meters) and weight (in kg) and returns BMI. bmi = weight / (height * height).