MathJax

Thursday, March 31, 2011

Expectations Under the Normal Distribution

Here are some of the more exotic or slightly quirky expectations under the normal distribution that you might encounter. I find that I need these now and again and it's annoying to have to re-derive them every time.

With the normal distribution defined as
\[N(x|\mu,\sigma^2) = \frac{1}{\sqrt{2\pi}\sigma} \exp \left( -\frac{(x - \mu)^2}{2\sigma^2}\right)\]
we have the following expectations:
\[E[(x-a)^2] = (\mu - a)^2 + \sigma^2\]
\[E[e^{ax}] = \exp\left(\frac{a^2\sigma^2}{2} + a\mu\right)\]
\[E[\log N(x|m,s^2)] = -\frac{1}{2}\log 2\pi - \log s - \frac{1}{2s^2}\left(\sigma^2 + (\mu-m)^2\right)\]

Also see the following for more expectations:

Tuesday, March 8, 2011

Merging multiple PDF files into one

Try
gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH \
   -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf
or, perhaps even better, install pdftk and use
pdftk in1.pdf in2.pdf in3.pdf cat output out.pdf