Skip to content

Commit

Permalink
added stats/Fisher-information-derivation.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuyi Xue committed Apr 13, 2022
1 parent c3798fa commit da33881
Showing 1 changed file with 120 additions and 0 deletions.
120 changes: 120 additions & 0 deletions stats/Fisher-information-derivation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Rederives https://en.wikipedia.org/wiki/Fisher_information#Definition."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"given $f(X; \\theta)$ is the maximum likelihood of $\\theta$ based on data $X$,"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\\begin{align*}\n",
"\\frac{\\partial}{\\partial \\theta} \\log f(X; \\theta) \n",
"&= \\frac{\\frac{\\partial}{\\partial \\theta} f(X; \\theta)}{ f(X;\\theta)} \\\\\n",
"\\frac{\\partial^2}{\\partial \\theta^2} \\log f(X; \\theta) \n",
"&= \\frac{\\left( \\frac{\\partial^2}{\\partial \\theta^2} f(X; \\theta) \\right ) f(X;\\theta) - \\frac{\\partial}{\\partial \\theta} f(X; \\theta) \\frac{\\partial}{\\partial \\theta} f(X ;\\theta) }{ f(X;\\theta) ^2} \\\\\n",
"&= \\frac{\\frac{\\partial^2}{\\partial \\theta^2} f(X; \\theta)}{ f(X;\\theta)} - \\left( \\frac{\\frac{\\partial} {\\partial \\theta} f(X; \\theta)}{f(X ;\\theta)} \\right )^2 \\\\\n",
"&= \\frac{\\frac{\\partial^2}{\\partial \\theta^2} f(X; \\theta)}{ f(X;\\theta)} - \\left( \\frac{\\partial}{\\partial \\theta} \\log f(X; \\theta) \\right )^2\n",
"\\end{align*}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The expectation of the first part is equal to zero"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\\begin{align*}\n",
"\\mathbb{E} \\left[ \\frac{\\frac{\\partial^2}{\\partial \\theta^2} f(X; \\theta)}{ f(X;\\theta)} \\bigg| \\theta \\right ]\n",
"&= \\int_{X} \\frac{\\frac{\\partial^2}{\\partial \\theta^2} f(X; \\theta)}{ f(X;\\theta)} f(X; \\theta) dX \\\\\n",
"&= \\int_{X} \\frac{\\partial^2}{\\partial \\theta^2} f(X; \\theta) dX \\\\\n",
"&= \\frac{\\partial^2}{\\partial \\theta^2} \\int_X f(X;\\theta) dX \\\\\n",
"&= \\frac{\\partial^2}{\\partial \\theta^2} 1 \\\\\n",
"&= 0\n",
"\\end{align*}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\\begin{align*}\n",
"\\mathbb{E}\\left[ \\frac{\\partial}{\\partial \\theta} \\log L(X; \\theta) \\bigg | \\theta \\right ]\n",
"&= - \\mathbb{E}\\left[ \\left( \\frac{\\partial}{\\partial \\theta} \\log f(X; \\theta) \\right )^2 \\bigg | \\theta \\right]\n",
"\\end{align*}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"which is the negative of variance of the score $\\frac{\\partial}{\\partial \\theta} \\log f(X; \\theta)$ since the expectation of the score is also 0:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\\begin{align*}\n",
"\\mathbb{E}\\left[ \\frac{\\partial}{\\partial \\theta} \\log f(X; \\theta) | \\theta \\right] \n",
"&= \\mathbb{E}\\left[ \\frac{ \\frac{\\partial}{\\partial \\theta} f(X; \\theta)}{f(X;\\theta)} \\bigg| \\theta \\right] \n",
"&= \\int_X \\frac{ \\frac{\\partial}{\\partial \\theta} f(X; \\theta)}{f(X;\\theta)} f(X;\\theta) dX \\\\\n",
"&= \\int_X \\frac{\\partial}{\\partial \\theta} f(X; \\theta) dX \\\\\n",
"&= \\frac{\\partial}{\\partial \\theta} \\int_X f(X; \\theta) dX \\\\\n",
"&= \\frac{\\partial}{\\partial \\theta} 1 \\\\\n",
"&= 0\n",
"\\end{align*}"
]
},
{
"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.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit da33881

Please sign in to comment.