[R] A vector of normal distributed values with a sum-to-zero constraint
Marc Marí Dell'Olmo
marceivissa at gmail.com
Tue Apr 1 14:56:24 CEST 2014
Anyone knows how to generate a vector of Normal distributed values
(for example N(0,0.5)), but with a sum-to-zero constraint??
The sum would be exactly zero, without decimals.
I made some attempts:
> l <- 1000000
> aux <- rnorm(l,0,0.5)
> s <- sum(aux)/l
> aux2 <- aux-s
> aux<- -sum(aux[2:l])
but the sum is not exactly zero and not all parameters are N(0,0.5)
Perhaps is obvious but I can't find the way to do it..
Thank you very much!
More information about the R-help