Search code examples
rnormal-distributiondata-visualization

Plotting the normal quantile function with R


I would like to make a graph of the quantile function of the standard normal distribution using R. I use the command

plot(qnorm,ylim=c(-4,4))

and I get this graph

enter image description here

However, the graph that I get is truncated at around $-2$ and around $2$. I would like to see something like this picture

enter image description here

The last picture was generated using the command

plot(1:99999/10^5,qnorm(1:99999/10^5),type="l")

but it is inefficient and slow.

Why is R making the truncated graph? What command should I use to make a graph without truncation?

Any help is much appreciated!


Solution

  • This should be sufficient:

    plot(qnorm,from=pnorm(-4),to=pnorm(4))
    

    If you'd like it a bit smoother where the radius of curvature is small, I'd suggest increasing the n parameter a little, e.g.:

    plot(qnorm,from=pnorm(-4),to=pnorm(4),n=201)
    

    see ?plot.function and ?curve