Search code examples
rjuliadistributionnormal-distributionquantile

Julia's equivalent of R's qnorm()?


I am trying to "translate" these lines from R to Julia:

n <- 100
mean <- 0
sd <- 1
x <- qnorm(seq(1 / n, 1 - 1 / n, length.out = n), mean, sd)

However, I have trouble with the qnorm function. I've searched for "quantile function" and found the quantile() function. However, the R's version returns a vector of length 100, while the Julia's version returns a vector of length 5.

Here's my attempt:

import Distributions
n = 100
x = Distributions.quantile(collect(range(1/n, stop=1-1/n, length=n))) 

Solution

  • Under Julia 1.1 you should broadcast the call to quantile like this:

    quantile.(Normal(0, 1), range(1/n, 1-1/n, length = n))