Full_Name: Marco Vezzoli Version: 2.2.0 2.1.0 2.0.0 OS: Solaris, Windows, Linux Submission from: (NULL) (57.78.11.38) The dnorm functions yield a wrong value when the standard deviation is near to 1e-1 e.g.> dnorm(0,mean=0.04,sd=0.3)[1] 1.318039 this error is consistent in various version and os.
On Fri, 10 Feb 2006, marco.vezzoli at st.com wrote:> Full_Name: Marco Vezzoli > Version: 2.2.0 2.1.0 2.0.0 > OS: Solaris, Windows, Linux > Submission from: (NULL) (57.78.11.38) > > > The dnorm functions yield a wrong value when the standard deviation is near to > 1e-1 > e.g. >> dnorm(0,mean=0.04,sd=0.3) > [1] 1.318039What is wrong here? Try the textbook formula> x <- 0 > m <- 0.04 > sd <- 0.3 > 1/(sqrt(2*pi)*sd) * exp(-0.5*(x-m)^2/sd^2)[1] 1.318039> this error is consistent in various version and os.It _is_ good that R is consistent. I don't think we are going to believe you unless you give your credentials and state your `correct value' and your reasoning. -- 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
Prof Brian Ripley wrote:>>The dnorm functions yield a wrong value when the standard deviation is near to >>1e-1> What is wrong here? Try the textbook formula > > >>x <- 0 >>m <- 0.04 >>sd <- 0.3 >>1/(sqrt(2*pi)*sd) * exp(-0.5*(x-m)^2/sd^2) > > [1] 1.318039 >Even MS Excel gets this one right: =NORMDIST(0,0.04,0.3,FALSE) 1.31803947 Barry
marco.vezzoli at st.com writes:> Full_Name: Marco Vezzoli > Version: 2.2.0 2.1.0 2.0.0 > OS: Solaris, Windows, Linux > Submission from: (NULL) (57.78.11.38) > > > The dnorm functions yield a wrong value when the standard deviation is near to > 1e-1 > e.g. > > dnorm(0,mean=0.04,sd=0.3) > [1] 1.318039 > > this error is consistent in various version and os.What's wrong with it???> (pnorm(0.000001,mean=0.04,sd=0.3) - pnorm(0,mean=0.04,sd=0.3))/.000001[1] 1.318040 -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907