[Rd] Accuracy of dnorm (PR#8586)

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Feb 10 14:20:29 CET 2006


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.318039

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

> 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



More information about the R-devel mailing list