Hughes and Hase worked example 3.2.2 (p. 25)

Using tools from the stats submodule of scipy

Sampling resistors from a normal distribution with $\bar{R} = 100\, \Omega$ and $\sigma = 2\, \Omega$.

In [2]:
import numpy as np      # import numpy
from scipy import stats # import stats sub-module

Probability of selection a resistor with a value of $95\, \Omega$ or less

$$ P = \int_{-\infty}^{95} P_{DF}(R)\, dR \equiv C_{DF}(R) $$
In [6]:
mean = 100
sigma = 2

p = stats.norm.cdf(95, mean, sigma)
print('probability = ',p)
probability =  0.006209665325776132

This probability agrees with that given by H&H.

Probability of selection a resistor with a value in the range $99-101\, \Omega$

\begin{eqnarray*} P &=& \int_{99}^{101} P_{DF}(R)\, dR\\ &=& \int_{-\infty}^{101}P_{DF}(R)\, dR - \int_{-\infty}^{99} P_{DF}(R)\, dR \\ &=& C_{DF}(101) - C_{DF}(99) \end{eqnarray*}
In [7]:
p  = stats.norm.cdf(101, mean, sigma)   - stats.norm.cdf(99, mean, sigma)
print('probability = ',p)
probability =  0.38292492254802624

This probability agrees with that given by H&H.

In [8]:
%load_ext version_information
In [9]:
%version_information numpy, scipy
Out[9]:
SoftwareVersion
Python3.7.7 64bit [GCC 7.3.0]
IPython7.16.1
OSLinux 4.9.0 9 amd64 x86_64 with debian 9.13
numpy1.18.5
scipy1.5.0
Wed Aug 26 13:54:36 2020 EDT
In [ ]: