Monte Carlo Estimator for a quantile I am trying to understand how to compute a crude Monte Carlo estimator for an $\alpha-$quantile. I have read the algorithm from the book
Monte Carlo Methods and Models in Finance and Insurance, (Korn, Korn and Kroisandt, 2010, CRC Press)

I don´t understand how can I implement this algorithm in R with an simple example, supposing that I don´t know the distribution $F$ or is hard to compute, how to use the remark, i.e solve numerically $F(x)-\alpha=0$.
In this case for instance in R I found that I have the function ecdf() that gives as output the empirical distribution function of a vector $x$, my problem is how to define the $F(x)-\alpha=0$ and solve it numerically?
I am confused also because if I need to compute it numerically I will need the derivatives of $F$ but if I don´t know it explicitly it seems really difficult.
 A: The remark is rather ill-thought, as it confuses the theoretical quantile that is solution to $F(q_\alpha)=\alpha$ with the empirical quantile that is solution to $\hat{F}_n(\hat{q}_\alpha)=\alpha$. Assuming you have an iid sample $X_1,\ldots,X_n$  from $F$, it is always possible to derive $\hat{F}_n$ by the ecdf function in R:
#Assuming x is the notation for the sample
Fn=ecdf(x)
plot(Fn)
#Taking a particular value of alpha
alpha=0.1017
abline(h=alpha)


This picture tells you where the empirical quantile should be, roughly, without giving you the solution to the equation $\hat{F}_n(\hat{q}_\alpha)=\alpha$ that you can solve by dyadic divide-and-conquer strategies or by calling the quantile function.
If the probability $\alpha$ is arbitrary, there will be not exact solution to this equation$$\hat{F}_n(\hat{q}_\alpha)=\alpha$$since $\hat{F}_n$ only takes $n+1$ possible values. (This is also visible from the above graph.) In that case, the "solution" is found as the smallest observation for which $\hat{F}_n(x)$ is above $\alpha$, mimicking the resolution in the theoretical case where $$F^{-1}(\alpha)=\inf\{x\,|\, F(X)\geq \alpha \}$$
A: Basically, you need to sort the sample and take $\alpha\cdot N$th element. The R code would be
sort(sample)[length(sample)*alpha]

As Xi'an said, it will give $F^{-1}(\alpha)=\inf\{x\,|\, F(X)\geq \alpha \}$
