Compute Descriptive Statistics
Advanced · Write the code · from SciPy Statistics: Distributions, Hypothesis Tests, and Correlations
From the lesson: SciPy Statistics: Distributions, Hypothesis Tests, and Correlations
A pharmaceutical company develops a new headache medicine. They give it to 100 patients and a placebo to another 100. The treatment group reports slightly fewer headaches. But is that difference real, or just random chance? This is the question statistics answers.
Read the lessonGiven the salaries array, compute and print the mean, median, and standard deviation (with ddof=1), each rounded to 1 decimal place. Also compute and print the IQR (interquartile range) using scipy.stats.iqr(), rounded to 1 decimal place. Print each on a separate line.
import numpy as np
from scipy import stats
salaries = np.array([45000, 48000, 52000, 55000, 58000,
62000, 65000, 70000, 85000, 120000])
# Compute and print mean, median, std, iqr
More SciPy Statistics exercises
All Python exercises · 50 practice problems · Data Science & Machine Learning quiz