# Convergence of the distribution of 0.05 quantiles through Monte-Carlo simulation

I am trying to get admitted to a masters in quantitative finance (I come from a computer science background), so next week I will have 3h to solve an exam in statistical computing using my favourite language (they recommended either MATLAB, Python or R). The mock exam I was provided with asks the following:

Generate a 2-year time-series (500 observations) from a stable distribution with parameters $$\alpha = 1.5, \quad \beta = 0.0, \quad \gamma = 1.0, \quad \delta = 1.0$$

a) Find the distribution of the $0.05$ quantiles of 5-day overlapping returns obtained from the 2-year time-series of 1-day returns.

b) Prove (numerically or theoretically) that enough trials have been considered.

Note: taking $P_i$ as the price on the $i$-th day,

• 1-day returns: $R_{1}^{i} = \frac{P_{i+1} - P_{i}}{P_{i}}, \; i=1,\ldots,499$
• n-day returns: $R_{n}^{i} = \frac{P_{i+n} - P_{i}}{P_{i}}$.

I am a little bit confused about the whole thing, so I would like some help to check if I am approaching this problem correctly. Here is how I would solve it:

1) generate a 500 value time-series using this technique (I'm assuming they're referring to the alpha-stable family of distributions);

2) after playing around a bit, I'm able to obtain the 5-day returns time-series from the original 1-day returns time-series: $$R^{n}_{i} = (R^{1}_{i} + 1) (R^{1}_{i+1} + 1) \ldots (R^{1}_{i+n-1} + 1) - 1$$

3) compute the empirical distribution function of the 5-day returns, say $F(x)$;

4) estimate each quantile $q_{\eta}$ by $$\hat q_{\eta} = F^{-1}(\eta)$$

Note: To invert the empirical distribution function I would order the simulated values by their size and then pick the value at position $k = \min \{ n \in \{ 1, \ldots, N \} | n/N \geq \eta \}$

5) save the distribution of $0.05$ quantiles

6) repeat steps 1) through 5) a minimum number of times, $K$, that I need to determine through some convergence law or something.

Question: Any hints on how to determine $K$?

• My guess: in one of your steps, you're going to run into a function that has no closed form and/or can't be computed easily. – user59 May 5 '16 at 18:27

1. Normal returns should always be in $[-1,+\infty)$. I believe that the way you sample $R_i$ from Stable directly violates that. You might want to sample $\log (1+R_i)$ from Stable instead. The question is very poorly worded.

2. For the sampling distribution of a percentile you can invoke order statistics. It will follow a transformation of Beta distribution.

Edit: Regarding your comment on point 2:

If a random variable $X$ follows any continuous distribution with cdf $F(x)=P[X<x]$ then the random variable $U=F(X)$ will follow a uniform distribution. Or, going the other way round, if $U$ is uniform, then $X=F^{-1}(U)$ will have the required distribution.

Also note that $F$ is a monotonic transformation, that is to say if I have a sample $X_1>X_2>\cdots>X_n$ then the transformed $U_1>U_2>\cdots>U_n$.

One can show that if I draw a sample of $N$ from a uniform distribution, then the $k$th smallest, denoted $U_{(k)}$, will follow a Beta distribution $B(k, N-k+1)$, say with cdf $Q(u;k,N) = P[U_{(k)}<u]$. If I want to work with a given percentile $p$, then I can set $k=pN$, and the distribution of the percentile will have cdf $Q(u;pN, N)$.

Putting the two together yields that the cdf of the $p$th percentile of $N$ draws of $X$ will have cdf $Q(F(x);pN,N)$.

• can you please recommend some material (books, online lectures notes, etc.) from which I could learn about order statistics and how to use them to find the sampling distribution of a percentile? – Maya Jun 2 '16 at 17:23

That all looks correct to me. It might be a bit more natural to convert the one day returns into prices and then compute the five day returns from those, but it's of course equivalent.

For your final question, you are generating a sequence of random variables (the quantiles) and want to know how good your estimate of the mean is. A practical choice would be to estimate the standard error of the mean in the usual way.