0
$\begingroup$

Let's say that I have a vector $u$ of real values (say of length 100). I know that $u-v$ is normally distributed with mean $\mu$ and variance $\sigma^2$. I would like to calculate a vector of corresponding $v$ values.

So what I'm doing is like this: use $rnorm()$ to sample 10000 random values with mean $\mu$ and variance $\sigma^2$. Then for every value $u_i$ in $u$, I check which quantile $u_i$ is and then pick the value with the same quantile from the randomly generated values:

gen = rnorm(10000, mean=mu, sd=sigma)
for(i in 1:length(u)){
  q = sum( u <= u[i] )/length(u)
  v[i] = u[i] - quantile(gen, probs=q)
}

Is this correct? Are there any better ways to do it?

Is there a specific term for this procedure?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.