Segment 8

From Computational Statistics (CSE383M and CS395T)
Jump to navigation Jump to search

Calculation Problems

1. Show that <math>1/r</math> is a special case of Lognormal Prior

<math>p(x) = \frac{1}{\sqrt{2\pi} \sigma x } exp \left ( - \frac12 \left [ \frac{log(x) - \mu}{\sigma}\right ]^2\right )</math>

<math> \lim_{\sigma \to \infin} p(x) \propto \frac{1}{\sqrt{2\pi} \sigma x } \propto \frac1x </math>

2. Prove that Gamma(<math>\alpha , \beta</math>) has a single mode <math> \left ( \alpha - 1 \right ) / \beta </math> when <math> \alpha \ge 1 </math>

<math>\begin{align} Gamma(\alpha, \beta) &= \frac{\beta^{\alpha}}{\Gamma(\alpha)} x^{\alpha -1} e^{-\beta x}, &x > 0\\ \frac{d Gamma(\alpha, \beta)}{dx} &= 0\\ \frac{\beta^{\alpha} x^{\alpha -2} e^{-\beta x} (\alpha -1 -\beta x)}{\Gamma(\alpha)} &= 0\\ x &= \frac{\alpha -1}{\beta} \end{align} </math>

3. Show that the limiting case of the Student distribution as <math>\nu \rightarrow \infin</math> is the Normal distribution

Student distribution : <math>p(t) = \frac{\Gamma\left(\frac12 \left [\nu + 1\right] \right )}{\Gamma\left(\frac12 \nu \right ) \sqrt{\nu\pi}\sigma}\left(1 + \frac{1}{\nu} \left[ \frac{t - \mu}{\sigma}\right]^2\right)^{-\frac12 (\nu+ 1)} </math>

<math>\begin{align} \lim_{\nu \rightarrow \infin} \frac{\Gamma\left(\frac12 \left [\nu + 1\right] \right )}{\Gamma\left(\frac12 \nu \right ) \sqrt{\nu\pi}\sigma} &= \frac{1}{\sqrt{2\pi}\sigma}\\ \lim_{\nu \rightarrow \infin} \left(1 + \frac{1}{\nu} \left[ \frac{t - \mu}{\sigma}\right]^2\right)^{-\frac12 (\nu+ 1)} &= e^{-\frac12 \left(\frac{t - \mu}{\sigma}\right)^2 }\\ \lim_{\nu \rightarrow \infin} p(t) &=\frac{1}{\sqrt{2\pi}\sigma} e^{-\frac12 \left(\frac{t - \mu}{\sigma}\right)^2 } \end{align}</math>

Food for Thought Problems

2. Radioactive Decay

Radioactive atoms decay randomly. A sample of atoms in a time interval such that the number of atoms has not changed significantly can show that the decay is proportional to the interval of time. A quantity is at a exponential decay if it decreases at a rate proportional to its value.

<math> \begin{align} \frac{dN}{dt} &= -\lambda N\\ N(t) &= N_0 e^{-\lambda t} \end{align} </math>

Class Activity

Worked with Noah,Jin and Silu's homework problems.

from scipy.stats import norm,t
from scipy.optimize import fmin
f = open('./data/Events20130204.txt', 'r')
events = []
for line in f:
avg = np.mean(events)
std = np.sqrt(np.var(events)) 
normdis = norm(scale=std,loc=avg)
nvector = normdis.pdf(events)
nsump= sum(np.log(nvector))
tdis = t(5,loc=2,scale=1.2)
tvector = tdis.pdf(events)
tsump = sum(np.log(tvector))

def e((d, u, sigma)):
    td = t(d,loc=u,scale=sigma)
    return sum(np.log(td.pdf(events)))*(-1)
print fmin(e,(5,2,1.2))
print nsump
print tsump
print np.exp(tsump-nsump)
print avg
print std