{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Hughes and Hase Problem 3.8\n", "\n", "NOTE: In this notebook I use the `stats` sub-module of `scipy` for all statistics functions, including generation of random numbers. There are other modules with some overlapping functionality, e.g., the regular python random module, and the `scipy.random` module, but I do not use them here. The `stats` sub-module includes tools for a large number of distributions, it includes a large and growing set of statistical functions, and there is a unified class structure. (And namespace issues are minimized.) See https://docs.scipy.org/doc/scipy/reference/stats.html." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from scipy import stats" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### (i) Mean count rate\n", "\n", "If we use the minute as our unit of time, the determination of the mean count rate is trivial: it's $R = 270\\, \\mbox{min$^{−1}$}$. If we choose seconds, it's only slightly less trivial: $R=270/60 = 4.5\\, \\mbox{s$^{−1}$}$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### (ii) Error in the mean count rate\n", "We are sampling from a Poisson distribution, so the error given, by the standard deviation, is $\\sigma = \\sqrt{\\bar \\mu}$:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "sigma (min^-1) = 16.431676725154983 ; sigma (s^-1) = 0.27386127875258304\n" ] } ], "source": [ "sigma = np.sqrt(270)\n", "print('sigma (min^-1) =', sigma, '; sigma (s^-1) = ', sigma/60)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### (iii) Fractional error" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "fractional error = 0.06085806194501846\n" ] } ], "source": [ "print('fractional error =', sigma/270)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Expected counts in 15 minutes: $N = 15\\, \\mbox{min} \\times R$" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "expected in 15 minutes = 4050\n" ] } ], "source": [ "n_expected = 15*270\n", "print('expected in 15 minutes =', n_expected)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The probability of actually getting this number of counts is given by the probability mass function of the Poisson distribution:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "probability of getting exactly 4050 counts = 0.006268644164779241\n" ] } ], "source": [ "probability = stats.poisson.pmf(n_expected,n_expected)\n", "print('probability of getting exactly', n_expected,' counts =', probability)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Version information\n", "`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\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "%load_ext version_information" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/json": { "Software versions": [ { "module": "Python", "version": "3.11.5 64bit [MSC v.1916 64 bit (AMD64)]" }, { "module": "IPython", "version": "8.15.0" }, { "module": "OS", "version": "Windows 10 10.0.26100 SP0" }, { "module": "numpy", "version": "1.23.2" }, { "module": "scipy", "version": "1.11.1" } ] }, "text/html": [ "
Software | Version |
---|---|
Python | 3.11.5 64bit [MSC v.1916 64 bit (AMD64)] |
IPython | 8.15.0 |
OS | Windows 10 10.0.26100 SP0 |
numpy | 1.23.2 |
scipy | 1.11.1 |
Sat Feb 08 13:58:14 2025 Eastern Standard Time |