[1] 2.835954
2025-01-19
Representing the solution of a problem as a parameter of a hypothetical population, and using a random sequence of numbers to construct a sample of the population, from which statistical estimates of the parameter can be obtained.
Two major classes of numerical problems that arise in statistical inference
Although optimization is generally associated with the likelihood approach, and integration with the Bayesian approach, these are not strict classifications.
Consider the following the integration: \[\begin{align*} I = \int_{x=a}^{b} (x^2+x+2)\; \mathrm{d}x = \frac{17}{6} \approx 2.833 \end{align*}\]
The integral \(I\) can be represented as expectation \[\begin{align*} I &= \int_{x=a}^{b} (x^2+x+2)\; \mathrm{d}x = (b-a) \int_{x=a}^{b} (x^2+x+2) \frac{1}{b-a}\; \mathrm{d}x\\ &= (b-a) \operatorname{E}\left(X^2+X+2\right), \quad \text{where} \quad X \sim U(a,b). \end{align*}\]
Under Monte Carlo integration \(I\) is approximated as \[\begin{align*} \widehat{I} = (b-a) \frac{1}{n} \sum_{i=1}^{n}(x_i^2+x_i+2) \quad \text{with} \quad x_1,\ldots,x_n \quad \text{iid realizations from} \quad U(a,b). \end{align*}\]
Consider computing the \(r\)-th moment of the random variable having the pdf \[\begin{align*} f_X(x | \lambda, \alpha) = \frac{\lambda^{\alpha} x^{\alpha-1}\exp(-\lambda x)}{\Gamma(\alpha)};\; \text{for } x>0, \end{align*}\] which is defined as \[\begin{align*} \mu_r = E(X^r)=\int_{0}^{\infty} x \, f_X(x | \lambda, \alpha) dx. \end{align*}\] For given any \(\lambda\) and \(\alpha\), describe the Monte-Carlo integration for computing \(\mu_r\) for all \(r\).
Compute the following integral values, i) algebrically ii) using numerical integration (Simson’ rule/Trapezoidal rule) and iii) using Monte Carlo integration \[\begin{align*} &\mathrm{i)} \quad \int_{x=0}^{3} (x^2+x+2)\; \mathrm{d}x\\ &\mathrm{ii)} \quad \int_{x=0}^{1}\left[\cos(50x) + \sin(20x)\right]^2\; \mathrm{d}x \end{align*}\]
To calculate the integral, we generate \(x_1,\ldots,x_n\) iid \(U(0,1)\) random variables, and approximate \[\begin{align*} \int_{x=0}^{1}\left[\cos(50x) + \sin(20x)\right]^2 \mathrm{d}x \quad \text{with} \quad \sum_{i=1}^{n} \frac{h(x_i)}{n} \end{align*}\]
[1] 0.9828217
It is clear that the Monte Carlo average is converging, with value of 0.963 after 10,000 iterations.
Assume \(X \sim Exp(1)\) and \(Y \sim N(0,X)\), that is \(Y\) is normally distributed with a random variance. Use Monte Carlo estimation to estimate \(E(X|Y=4)\) and \(Var(X|Y=4)\).
Given the density function in \[\begin{align*} f(x)=\frac{1}{x\sqrt{2\pi}} e^{-\frac{(\log x)^2}{2}}, \; x>0 \end{align*}\]