[Rd] bug with dlnorm

HALL, BENJAMIN PW benjamin.hall at pw.utc.com
Wed Jul 5 22:03:11 CEST 2017


I've found some funny behavior in the dlnorm() function that I believe to be a bug.  For example, the following command:

> dlnorm( c(5e-323, 5e-324, 5e-325), 0, 0.3 )

Produces the output below, including the NaN value that should (ideally would be) zero.
[1]   0 NaN   0
Warning message:
In dlnorm(c(4.94065645841247e-323, 4.94065645841247e-324, 0), 0,  :
  NaNs produced

Calling the log() function directly seems to produce appropriate results, e.g.:
> log(c(5e-323,5e-324,5e-524))
[1] -742.1375 -744.4401      -Inf

I realize that I am working in the regime of very small numbers, and that these values are smaller than the value reported by .Machine$double.xmin == 2.225074e-308, but it would be better (for me, at least!) if this corner case(s?) was handled at a lower level.

I have found this behavior in the 64-bit versions (but NOT the 32-bit versions) of R that I have access to.  These include:
                R version 3.2.5 (2016-04-14) -- "Very, Very Secure Dishes"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
And
R version 3.3.0 (2016-05-03) -- "Supposedly Educational"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
And
R version 3.0.0 (2013-04-03) -- "Masked Marvel"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
And
R version 3.0.1 (2013-05-16) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)
And
R version 3.0.1 (2013-05-16) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

But NOT in any of the 32-bit versions I have access to, including:
R version 2.11.1 (2010-05-31)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
And
R version 3.0.0 (2013-04-03) -- "Masked Marvel"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)

Thanks,
Ben


	[[alternative HTML version deleted]]



More information about the R-devel mailing list