Dear R useRs, i wanted to ask if the folded normal destribution (Y = abs(X) with X normal distributed) with density and random number generator is implemented in R or in any R-related package so far? Maybe i can use the non-central chi-square distribution and rchisq(n, df=1, ncp>0) here? Thanks and best regards Andreas
Dear Andreas, try: library(distr) X <- Norm() ## standard normal distribution Y <- abs(X) plot(Y) Best regards, Matthias Andreas Wittmann wrote:> Dear R useRs, > > i wanted to ask if the folded normal destribution (Y = abs(X) with X > normal distributed) > with density and random number generator is implemented in R or in any > R-related package > so far? Maybe i can use the non-central chi-square distribution and > rchisq(n, df=1, ncp>0) here? > > Thanks and best regards > > Andreas > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Dr. Matthias Kohl www.stamats.de
It's trivial to do. In particular abs(rnorm(...)) will give you the random number generator. The term 'folded normal distribution' is normally only used for mean=0, when you just double the density, but the general result is ifelse(x > 0, 1, 0) * (dnorm(x, ...) + dnorm(-x, ...)) On Mon, 20 Oct 2008, Andreas Wittmann wrote:> Dear R useRs, > > i wanted to ask if the folded normal destribution (Y = abs(X) with X normal > distributed) > with density and random number generator is implemented in R or in any > R-related package > so far? Maybe i can use the non-central chi-square distribution and rchisq(n, > df=1, ncp>0) here? > > Thanks and best regards > > Andreas-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595