{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Hughes and Hase Problem 8.2" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from scipy import stats" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### (a)\n", "\n", "The reduced chi-squared statistic is defined as\n", "\n", "$$ \\chi^2_\\nu \\equiv \\frac{\\chi^2_{\\rm min}}{\\nu}, $$\n", "\n", "where $\\nu$ is the number of degrees of freedom. So in this part we have\n", "\n", "$$ \\chi^2_\\nu = \\frac{15.9}{10} = 1.59 $$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### (b)\n", "We can use the CDF of the chi-squared distribution to calculate the probability of getting a value of the \n", "reduced chi-squared statistic greater than of equal to 1.59:\n", "\n", "$$ P(\\chi^2_{\\rm min},\\nu) = 1 - C_{DF} $$ " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.10253102145831061" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1 - stats.chi2.cdf(15.9, 10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We find about a 10% chance of getting a value of $\\chi^2_\\nu$ this large." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### (c)\n", "In this part we have a a larger value of $\\chi^2{\\rm min}$, and more degrees of freedom, \n", "giving\n", "\n", "$$ \\chi^2_\\nu = \\frac{15.9}{100} = 1.59, $$\n", "which the same value found in part (a)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### (d)\n", "Using the CDF again, we the probability of getting this same value of $\\chi^2_\\nu$ now:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.0001599798564519972" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1 - stats.chi2.cdf(159, 100)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The probability is 0.016%. These is a very different probability than than that found in part (b), even though the fits have the same value of $\\chi^2_\\nu$, which illustrates the \n", "hazards of relying on that one simple diagnostic to make judgments. With the larger number of degrees of freedom, a value as large as $\\chi^2_\\nu = 1.59$ becomes much\n", "more improbable.\n" ] }, { "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 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": 4, "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.7 64bit [GCC 7.3.0]" }, { "module": "IPython", "version": "7.16.1" }, { "module": "OS", "version": "Linux 3.10.0 1062.9.1.el7.x86_64 x86_64 with centos 7.7.1908 Core" }, { "module": "numpy", "version": "1.18.5" }, { "module": "scipy", "version": "1.5.2" } ] }, "text/html": [ "
SoftwareVersion
Python3.7.7 64bit [GCC 7.3.0]
IPython7.16.1
OSLinux 3.10.0 1062.9.1.el7.x86_64 x86_64 with centos 7.7.1908 Core
numpy1.18.5
scipy1.5.2
Thu Aug 06 14:39:15 2020 EDT
" ], "text/latex": [ "\\begin{tabular}{|l|l|}\\hline\n", "{\\bf Software} & {\\bf Version} \\\\ \\hline\\hline\n", "Python & 3.7.7 64bit [GCC 7.3.0] \\\\ \\hline\n", "IPython & 7.16.1 \\\\ \\hline\n", "OS & Linux 3.10.0 1062.9.1.el7.x86\\_64 x86\\_64 with centos 7.7.1908 Core \\\\ \\hline\n", "numpy & 1.18.5 \\\\ \\hline\n", "scipy & 1.5.2 \\\\ \\hline\n", "\\hline \\multicolumn{2}{|l|}{Thu Aug 06 14:39:15 2020 EDT} \\\\ \\hline\n", "\\end{tabular}\n" ], "text/plain": [ "Software versions\n", "Python 3.7.7 64bit [GCC 7.3.0]\n", "IPython 7.16.1\n", "OS Linux 3.10.0 1062.9.1.el7.x86_64 x86_64 with centos 7.7.1908 Core\n", "numpy 1.18.5\n", "scipy 1.5.2\n", "Thu Aug 06 14:39:15 2020 EDT" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "version_information numpy, scipy" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.7" } }, "nbformat": 4, "nbformat_minor": 2 }