Skip to content

Commit

Permalink
add modes image
Browse files Browse the repository at this point in the history
  • Loading branch information
fzimmermann89 committed Nov 9, 2020
1 parent 59d503a commit b9e198a
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 0 deletions.
Binary file added Tex/images/modes.pdf
Binary file not shown.
201 changes: 201 additions & 0 deletions Tex/images/src/modes.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from scipy.special import gamma\n",
"from scipy.stats import poisson"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x=np.arange(0,5)\n",
"mu=.1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.bar(x,poisson.pmf(x,mu))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import scipy.stats"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from scipy.stats import nbinom"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def nb(x,mu,M):\n",
" r=M\n",
" p=r/(mu+r)\n",
" return nbinom.pmf(x,r,p)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mu=.1\n",
"x=np.arange(0,10)\n",
"\n",
"plt.step(x-.5,poisson.pmf(x,mu),'-',label='poisson')\n",
"Ms=[1,2,5,10,50,100]\n",
"for i in Ms:\n",
" plt.step(x-.5,nb(x,mu,i),'-',label=f\"M={i}\")\n",
" \n",
"plt.legend()\n",
"plt.yscale('log')\n",
"plt.xticks(x,[str(i) for i in x])\n",
"plt.xlim(-.5,max(x)-.5)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Ms=[1,2,5,10,100]\n",
"plt.figure(figsize=(8,4))\n",
"\n",
"for i,M in enumerate(Ms):\n",
" off=(i)*1/(len(Ms)+3)\n",
" plt.bar(x+off,nb(x,mu,M),label=f\"M={M}\",width=1/(1.3*(len(Ms)+3)))\n",
"\n",
"\n",
"plt.bar(x+(i+1)*1/(len(Ms)+3),poisson.pmf(x,mu),label='Poisson',width=1/(1.3*(len(Ms)+3)))\n",
"plt.yscale('log')\n",
"\n",
"plt.xticks(x+0.3,[str(i) for i in x])\n",
"plt.xlabel('Photon Count')\n",
"plt.ylabel('Frequency')\n",
"\n",
"plt.legend()\n",
"plt.tight_layout()\n",
"plt.savefig('../modes.pdf')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"M=10\n",
"mu=2\n",
"\n",
"v=mu+mu**2/M\n",
"nbinom(r,p).stats(moments='mv'),v"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"p*r/(1-p)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"n*((1.0 / p) - 1.0)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"P"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"v=2\n",
"mu=1\n",
"v=(1 + 1/r)*mu\n",
"p=(v-mu)/v\n",
"r=mu/(v-mu)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"nbinom(r,p).stats(moments='mv')"
]
},
{
"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.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
5 changes: 5 additions & 0 deletions Tex/theory.tex
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ \section{Statistics}

Following the idea of Trost et. al, this can be used so estimate the noise of an intensity correlation measurement, even though the actual signal will break the assumption of having uncorrelated photon counts.

\begin{figure}
\centering
\includegraphics[width=0.8\linewidth]{images/modes.pdf}
\caption[Photon Statistics with different numbers of Modes]{Photon statistics with different numbers of modes $M$ and equal mean of 0.1\,photons. A lower number of modes corresponds the an higher probability of observing multi photon events. The limit of a high number of modes is a Poisson distribution.}
\end{figure}
\section{Kossel Lines}
X-Ray radiation originating from within a single crystal gets Bragg reflected at the lattice planes, causing Intensity variation in $90^o-\theta$ around the direction $k_{hkl}$, forming the \textit{Kossel Cones}. On the spherical detector centered at at the crystal, the points with influenced intensity would lie on circles with radii determined by ...

Expand Down

0 comments on commit b9e198a

Please sign in to comment.