# Monte-Carlo Simulations with multiple random variables

I have the following observation model : $y_i=x_i+a_i$, where $a_i$ is a Gaussian random variable whose mean is function of a uniform random variable $b_i$. I have designed, $\hat{x}_i$, an estimator of $x_i$ and would like to evaluate its performance using Monte-Carlo simulations. I use the following logic, which I appreciate if you can criticize:

For i=1:I
n=0
Generate an $x_i$ uniformly from a given distribution
for j=1:J
Generate $b_j$ as a r.v. from a given uniform distribution
for k=1:K
Generate $a_jk$ as a normal r.v. conditional to $b_j$
Generate synthetic data: $y_jk=x_i+a_jk$
Obtain $\hat{x}_n$ using $y_jk$
n++
end
end
find  $\hat{x}_i$ as the average of  $\hat{x}_n$

end

calculate the RMS of error.


Note that the distributions of $a$ and $b$ can be anything. However, I don't have access to the joint PDF's. Instead I have the following:

• The distribution of $x$
• The distribution of $b$
• The distribution of $a|b$
• Your model description is incomplete: how are x, a, and b related in a joint probabilistic model? If there are repeated measures, how are they connected with the variables? Introduce double or triple indices in the first equation. Without this description, the three levels of loops in your pseudo-code are delicate to justify or criticise. – Xi'an Nov 9 '14 at 11:41
• have edited my description. I hope it's clearer now. – Pioneer83 Nov 9 '14 at 21:22
• Thanks. In that case, do you want to check the error conditional on $X=x_i$? Otherwise, I would use a single loop, instead of three. The RMSE should be the average of the $(\hat{x}_i-x_i)^2$ so why compute an average of $\hat{x}_i$'s? – Xi'an Nov 9 '14 at 21:29
• Well, to avoid outliers effect, one should have a loop for each random variable (my understanding). So, I have a loop t to pick $x_i$ then generate differtent $a_i$'s in an inner loop. But because the distirbution of $a_i$ dependes on $b_i$ I added middle loop to generate $b$'s. – Pioneer83 Nov 9 '14 at 21:57
• Once again, I see no reason to have more than a single loop. If there is a possibility of outliers in your simulation, it should be either barred from the simulating mechanism or else incorporated in the model, because otherwise the Monte Carlo results cannot be trusted. – Xi'an Nov 10 '14 at 19:35