Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Did another problem
  • Loading branch information
jeremyteitelbaum committed Apr 12, 2018
1 parent 0cab477 commit eafa025
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 360 deletions.
310 changes: 33 additions & 277 deletions BDA 3.10.11.ipynb
Expand Up @@ -179,7 +179,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -205,7 +205,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -240,7 +240,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 11,
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -282,301 +282,57 @@
},
{
"cell_type": "code",
"execution_count": 225,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[-2. , -2. , -2. , ..., -2. ,\n",
" -2. , -2. ],\n",
" [-1.9798995 , -1.9798995 , -1.9798995 , ..., -1.9798995 ,\n",
" -1.9798995 , -1.9798995 ],\n",
" [-1.95979899, -1.95979899, -1.95979899, ..., -1.95979899,\n",
" -1.95979899, -1.95979899],\n",
" ...,\n",
" [ 1.95979899, 1.95979899, 1.95979899, ..., 1.95979899,\n",
" 1.95979899, 1.95979899],\n",
" [ 1.9798995 , 1.9798995 , 1.9798995 , ..., 1.9798995 ,\n",
" 1.9798995 , 1.9798995 ],\n",
" [ 2. , 2. , 2. , ..., 2. ,\n",
" 2. , 2. ]])"
]
},
"execution_count": 225,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Y\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 231,
"execution_count": 58,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.82616995 1.33837647 1.80934486 2.49570902 5.68990452]\n"
"With Rounding\n",
"mu: 10.40618592964824 0.49106811542637807 [ 9.10552764 10.01005025 10.38693467 10.7638191 11.74371859]\n",
"sigma: 1.3555419607805625 0.5063610652735683 [0.61111977 0.90438284 1.18631786 1.55614414 3.30679651]\n"
]
}
],
"source": [
"Psigma=list(map(sum,np.exp(Z2-np.max(Z2))))\n",
"p=Psigma/sum(Psigma)\n",
"s=np.random.choice(np.exp(np.linspace(-2,2,200)),p=p,size=1000)\n",
"print(np.percentile(s,q=[2.5,25,50,75,97.5]))"
]
},
{
"cell_type": "code",
"execution_count": 178,
"metadata": {},
"outputs": [],
"source": [
"p=[1/3,1/3].append([1/200.0]*198)"
]
},
{
"cell_type": "code",
"execution_count": 180,
"metadata": {},
"outputs": [],
"source": [
"p=[1/3,1/3]\n",
"p.append([1/200.0]*198)\n"
"print('With Rounding')\n",
"Pmu=list(map(np.sum,np.exp(Z1-np.max(Z1)).T))\n",
"p=Pmu/np.sum(Pmu)\n",
"mu_samples=np.random.choice(np.linspace(3,18,200),p=p,size=5000)\n",
"print('mu:',np.mean(mu_samples),np.var(mu_samples),np.percentile(mu_samples,q=[2.5,25,50,75,97.5]))\n",
"Psigma=list(map(np.sum,np.exp(Z1-np.max(Z1))))\n",
"p=Psigma/np.sum(Psigma)\n",
"sigma_samples=np.random.choice(np.exp(np.linspace(-2,4,200)),p=p,size=5000)\n",
"print('sigma:',np.mean(sigma_samples),np.var(sigma_samples),np.percentile(sigma_samples,q=[2.5,25,50,75,97.5]))\n"
]
},
{
"cell_type": "code",
"execution_count": 181,
"execution_count": 55,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0.3333333333333333,\n",
" 0.3333333333333333,\n",
" [0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005,\n",
" 0.005]]"
]
},
"execution_count": 181,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"Ignoring Rounding\n",
"mu: 10.3954824120603 0.49760868662407504 [ 9.03015075 10.01005025 10.38693467 10.7638191 11.81909548]\n",
"sigma: 1.4352129437474488 0.5752559640752803 [0.68945124 0.99000008 1.26005551 1.65286899 3.30679651]\n"
]
}
],
"source": [
"p"
"print('Ignoring Rounding')\n",
"Pmu=list(map(np.sum,np.exp(Z2-np.max(Z2)).T))\n",
"p=Pmu/np.sum(Pmu)\n",
"s=np.random.choice(np.linspace(3,18,200),p=p,size=5000)\n",
"print('mu:',np.mean(s),np.var(s),np.percentile(s,q=[2.5,25,50,75,97.5]))\n",
"Psigma=list(map(np.sum,np.exp(Z2-np.max(Z2))))\n",
"p=Psigma/np.sum(Psigma)\n",
"s=np.random.choice(np.exp(np.linspace(-2,4,200)),p=p,size=5000)\n",
"print('sigma:',np.mean(s),np.var(s),np.percentile(s,q=[2.5,25,50,75,97.5]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit eafa025

Please sign in to comment.