Skip to content

Instantly share code, notes, and snippets.

@lgarrison
Last active October 25, 2019 19:18
Show Gist options
  • Save lgarrison/7e41ee280c57554e256b834ac5c3f753 to your computer and use it in GitHub Desktop.
Save lgarrison/7e41ee280c57554e256b834ac5c3f753 to your computer and use it in GitHub Desktop.
sigma8 in Scale-Free Cosmologies
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# $\\sigma_8$ in power-law cosmologies\n",
"Author: Lehman Garrison (<https://lgarrison.github.io>)\n",
"\n",
"#### Update 10/25/2019:\n",
"Thanks to Daniel Eisenstein for deriving an even simpler expression! The notebook has been updated with this version."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Power-law cosmologies ($P(k) = A k^n$) have an analytic form for $\\sigma^2(R)$ with a spherical tophat window $W_T$:\n",
"\n",
"$$\\begin{align}\n",
"\\sigma^2(R) &= \\int \\frac{d^3k}{(2\\pi)^3}\\tilde W_T^2(kR)P(k) \\\\\n",
" &= A \\int_0^\\infty \\frac{k^2dk}{2\\pi^2} \\left[\\frac{3(\\sin(kR) - kR\\cos(kR))}{(kR)^3}\\right]^2 k^n\\\\\n",
" &= \\frac{9 A (n+1) 2^{-n-1} R^{-n-3} \\sin \\left(\\frac{\\pi n}{2}\\right) \\Gamma (n-1)}{\\pi^2 (n-3)}\n",
"\\end{align}\n",
"$$\n",
"where we used the Fourier transform $\\tilde W_T(kR)$ of the spherical tophat window. The result in the last line (obtained via Mathematica) is only valid for $-3 < n < 1$; otherwise, the variance is undefined.\n",
"\n",
"However, the result is numerically unstable if $n$ is an integer in this range, since the function $\\Gamma(n-1)$ in the numerator goes to infinity for 0 and the negative integers.\n",
"\n",
"The $\\sigma^2(R)$ function itself is perfectly smooth and finite in this range, as seen below:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEICAYAAABxiqLiAAAABHNCSVQICAg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P/XITvpPsK5xuu+mXgs+absRAzKzCz0UFsNw/Y4y8ek/AdPuudqb/thvoezzOzTH/LZoH/+QO9h4XAf+KbTbKvCY+m4huqv8fh+IqdJDgVEEkYzrnlwF345oxYjG9ui/f9Ly8ChgLvOOeq8B3OWeT/vQ+B/8A3b/oq4EX/soF6Dkjx/+6PgN6HvPrdbij87/EhfB/4jx3sPZjZl4BO59z9wE+BI81s/ylXp/HpAjIVtUAENB+IiIiERi0QEREJiQqIiIiERAVERERCogIiIiIhUQEREZGQqICIiEhIVEBERCQk/x/IaaPWT9oyewAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"from scipy.special import gamma\n",
"def sigma2_mathematica(n,R):\n",
" return 9*(n + 1)*2**(-n - 1)*R**(-n - 3)*np.sin(np.pi*n/2)*gamma(n - 1)/(np.pi**2*(n-3))\n",
"\n",
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"nrange = np.linspace(-3,1,101, endpoint=False)\n",
"plt.plot(nrange, sigma2_mathematica(nrange,1))\n",
"plt.xlabel('Power law index $n$')\n",
"plt.ylabel('Tophat variance $\\sigma^2(R=1)$');\n",
"plt.yscale('log')\n",
"\n",
"plt.savefig('scale_free_sigma8.pdf')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For plotting purposes, we avoided exact integers in the $n$ range and used $A=1$.\n",
"\n",
"So, to find a numerically stable variant of the above expression, we need to re-write it to avoid evaluating $\\Gamma(n-1)$ at negative integers.\n",
"\n",
"Using some properties of the $\\Gamma$ function (<https://dlmf.nist.gov/5.5>), we can arrive at the following expression:\n",
"\n",
"$$\n",
"\\sigma^2(R) = \\frac{9 A R^{-(3+n)}}{2 \\pi^{3/2}} \\frac{\\Gamma[(3+n)/2]}{\\Gamma[(2-n)/2] (n-3)(n-1)}\n",
"$$\n",
"\n",
"It's worth noting that this expression is exact; we have not used any approximations.\n",
"\n",
"Note: a previous version of this notebook had two expressions, one for even poles and one for odd, which are now combined into one expression."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def sigma2_robust(n,R):\n",
" return 9*R**-(3 + n)/(2*np.pi**(3/2)) * gamma((3 + n)/2)/(gamma((2 - n)/2)*(n - 3)*(n - 1))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"def test_all():\n",
" n = np.array([-2.9, -2.5, -2, -1.3, -1, -0.01, 0, 0.001, 0.75])\n",
" R = 8.\n",
" \n",
" res = pd.DataFrame(index=n)\n",
" res.index.name = 'n'\n",
" res['Naive'] = sigma2_mathematica(n, R)\n",
" res['Stable'] = sigma2_robust(n, R)\n",
" \n",
" return res"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/lgarrison/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:4: RuntimeWarning: invalid value encountered in multiply\n",
" after removing the cwd from sys.path.\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Naive</th>\n",
" <th>Stable</th>\n",
" </tr>\n",
" <tr>\n",
" <th>n</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>-2.900</th>\n",
" <td>0.432508</td>\n",
" <td>0.432508</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-2.500</th>\n",
" <td>0.047497</td>\n",
" <td>0.047497</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-2.000</th>\n",
" <td>-inf</td>\n",
" <td>0.011937</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-1.300</th>\n",
" <td>0.002945</td>\n",
" <td>0.002945</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-1.000</th>\n",
" <td>NaN</td>\n",
" <td>0.001781</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-0.010</th>\n",
" <td>0.000471</td>\n",
" <td>0.000471</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0.000</th>\n",
" <td>NaN</td>\n",
" <td>0.000466</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0.001</th>\n",
" <td>0.000466</td>\n",
" <td>0.000466</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0.750</th>\n",
" <td>0.000392</td>\n",
" <td>0.000392</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Naive Stable\n",
"n \n",
"-2.900 0.432508 0.432508\n",
"-2.500 0.047497 0.047497\n",
"-2.000 -inf 0.011937\n",
"-1.300 0.002945 0.002945\n",
"-1.000 NaN 0.001781\n",
"-0.010 0.000471 0.000471\n",
" 0.000 NaN 0.000466\n",
" 0.001 0.000466 0.000466\n",
" 0.750 0.000392 0.000392"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res = test_all()\n",
"res"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\\begin{tabular}{lrr}\n",
"\\toprule\n",
"{} & Naive & Stable \\\\\n",
"n & & \\\\\n",
"\\midrule\n",
"-2.900 & 0.432508 & 0.432508 \\\\\n",
"-2.500 & 0.0474965 & 0.0474965 \\\\\n",
"-2.000 & -inf & 0.0119366 \\\\\n",
"-1.300 & 0.00294465 & 0.00294465 \\\\\n",
"-1.000 & nan & 0.00178104 \\\\\n",
"-0.010 & 0.00047106 & 0.00047106 \\\\\n",
" 0.000 & nan & 0.000466274 \\\\\n",
" 0.001 & 0.000465801 & 0.000465801 \\\\\n",
" 0.750 & 0.000392073 & 0.000392073 \\\\\n",
"\\bottomrule\n",
"\\end{tabular}\n",
"\n"
]
}
],
"source": [
"print(res.to_latex(float_format=lambda s:'{:.6g}'.format(s)))"
]
},
{
"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.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment