# Estimating number of Monte Carlo runs to evaluate a percentile

I have a complex distribution which I can numerically sample.

I'd like to estimate a percentile (let's say 90%) using Monte-Carlo simulations. What I'm doing is:

1. I run 1 million of independent simulations and I get 1 million of samples from the distribution.
2. I order them in ascending order, and I take the one that it's in the 900000th position.

Assuming that this way of proceeding is correct, how can I theoretically estimate the number of runs so that the error in the estimation is roughly within i.e. 1%?

All I can say about the underlying distribution is that it's roughly analogous to a normal distribution divided by a chi distribution, if that's of any help.

• This is just a complicated way of asking about binomial proportion confidence intervals, so you are likely to find useful information in the linked search.
– whuber
Dec 24, 2016 at 15:03
• Why don't you edit this again taking out what is irrelevant and make it really clear what your problem is. Dec 24, 2016 at 20:46
• @MichaelChernick If I knew that those things were irrelevant I wouldn't have added them. By the way, I believe that what I'm asking is quite clear: how can I estimate the number of samples to use to estimate the inverse CDF at a given percentile within a given accuracy?
– xanz
Dec 24, 2016 at 21:46
• The question is rather vague, you don't seem to know the distribution, or it is so complicated that working with it analytically is not possible anyway. In these circumstances, why not just ... Do your simulation 100 times with $n = 10^6$ ... and see if the bulk (say 95%) of the answers lie within a 1% range (or whatever you require). If they do not, increase the number of simulations to $n=10^7$, and try again. If not, try $n=10^8$, etc If you never get there, you may need to relax your requirements. ........ Dec 25, 2016 at 16:45
• Thank you for the clarification. You are asking for a tolerance interval for $F$.
– whuber
Dec 25, 2016 at 23:34

If $Z \sim N(0, 1)$ and $Y \sim \chi^2_n$ and if Z and Y are independent, then it is well known that the ratio $T = \frac{Z}{\sqrt{Y/n}} \sim t_n$. If you approximately have the ratio of a normal to a chi with n degrees of freedom (independent), then it sounds like you approximately have a scaled t distribution. You can use properties of the t to estimate the quantile.
• I said "roughly" on purpouse because the degree of dependency is very modest. But the accuracy I require on the estimates is very high. That's why I didn't add details, I wanted to know if there's a method that's generally valid for choosing $n$ regardless of the underlying distribution