{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Hughes and Hase, Problem 3.5\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from scipy import stats" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Introduction\n", "\n", "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)$.) \n", "I will use the $C_{DF}$ from the `stats` sub-module of `scipy`." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "mean = 502\n", "sigma = 14" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Probability that the bag contains less than $500\\, \\mbox{g}$:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.4432015031835318" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stats.norm.cdf(500, mean, sigma)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The probability is about 44%." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Probability that the bag contains at least $530\\, \\mbox{g}$:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.02275013194817921" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1 - stats.norm.cdf(530, mean, sigma)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "#### Version information\n", "`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.\n", "\n", "`version_information` is installed on the linux network at Bucknell" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "%load_ext version_information" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/json": { "Software versions": [ { "module": "Python", "version": "3.7.8 64bit [GCC 7.5.0]" }, { "module": "IPython", "version": "7.17.0" }, { "module": "OS", "version": "Linux 3.10.0 1160.36.2.el7.x86_64 x86_64 with centos 7.9.2009 Core" }, { "module": "numpy", "version": "1.19.1" }, { "module": "scipy", "version": "1.5.0" } ] }, "text/html": [ "
Software | Version |
---|---|
Python | 3.7.8 64bit [GCC 7.5.0] |
IPython | 7.17.0 |
OS | Linux 3.10.0 1160.36.2.el7.x86_64 x86_64 with centos 7.9.2009 Core |
numpy | 1.19.1 |
scipy | 1.5.0 |
Fri Feb 04 15:03:33 2022 EST |