Editor

Work with the Normal Distribution

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 lesson

Battery life for a phone model follows a normal distribution with mean 10 hours and standard deviation 1.5 hours. Using scipy.stats.norm, calculate: (1) the probability that a random phone lasts more than 12 hours (print as percentage rounded to 1 decimal), (2) the battery life at the 90th percentile (rounded to 2 decimal places). Print each on a separate line.

from scipy import stats
# Battery life: mean=10, std=1.5
battery = stats.norm(loc=10, scale=1.5)
# Probability of lasting more than 12 hours (%)
# 90th percentile battery life

More SciPy Statistics exercises

All Python exercises · 50 practice problems · Data Science & Machine Learning quiz