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 for more information and instructions for package installation.

version_information is installed on the linux network at Bucknell

In [5]:
%load_ext version_information
In [6]:
%version_information numpy, scipy
Out[6]:
SoftwareVersion
Python3.7.8 64bit [GCC 7.5.0]
IPython7.17.0
OSLinux 3.10.0 1160.36.2.el7.x86_64 x86_64 with centos 7.9.2009 Core
numpy1.19.1
scipy1.5.0
Fri Feb 04 15:03:33 2022 EST
In [ ]: