Hughes and Hase, Problem 3.5¶

In [1]:
import numpy as np
from scipy import stats

Introduction¶

The probabilities in this problem can be evaluated with the cumulative distribution function, or $C_{DF}$, of a normal distribution. (This $C_{DF}$ also has the name $\mbox{Erf}(x)$.) I will use the $C_{DF}$ from the stats sub-module of scipy.

In [2]:
mean = 502
sigma = 14

Probability that the bag contains less than $500\, \mbox{g}$:¶

In [3]:
stats.norm.cdf(500, mean, sigma)
Out[3]:
0.4432015031835318

The probability is about 44%.

Probability that the bag contains at least $530\, \mbox{g}$:¶

In [4]:
1 - stats.norm.cdf(530, mean, sigma)
Out[4]:
0.02275013194817921

The probability is about 2.3%, and so, out of 1000 bags, you would expect about 23 to have a mass greater than 530 g.

Version information¶

version_information is from J.R. Johansson (jrjohansson at gmail.com); see Introduction to scientific computing with Python . If not already installed on your machine, run pip install --upgrade version_information from the terminal

In [5]:
%load_ext version_information
%version_information numpy, scipy
Out[5]:
SoftwareVersion
Python3.11.5 64bit [MSC v.1916 64 bit (AMD64)]
IPython8.15.0
OSWindows 10 10.0.26100 SP0
numpy1.23.2
scipy1.11.1
Sat Feb 08 13:55:56 2025 Eastern Standard Time
In [ ]: