Re: [Rd] What should dnorm(0, 0, -Inf) return?

2019-12-09 Thread peter dalgaard
I have committed a fix for r-devel (dnorm only). -pd > On 9 Dec 2019, at 08:49 , Martin Maechler wrote: > >> peter dalgaard >>on Sun, 8 Dec 2019 12:11:50 +0100 writes: > >> Yes, that looks like a bug and an easily fixable one too. > > agreed. > >> However, I spy another issue:

Re: [Rd] What should dnorm(0, 0, -Inf) return?

2019-12-08 Thread Martin Maechler
> peter dalgaard > on Sun, 8 Dec 2019 12:11:50 +0100 writes: > Yes, that looks like a bug and an easily fixable one too. agreed. > However, I spy another issue: Why do we check the > !R_FINITE(x) && mu == x before checking for sd < 0 ? The > difference is whether we

Re: [Rd] What should dnorm(0, 0, -Inf) return?

2019-12-08 Thread peter dalgaard
Yes, that looks like a bug and an easily fixable one too. However, I spy another issue: Why do we check the !R_FINITE(x) && mu == x before checking for sd < 0 ? The difference is whether we return ML_NAN; or ML_ERR_return_NAN; but surely negative sd should always be an error? I'd be inclined

Re: [Rd] What should dnorm(0, 0, -Inf) return?

2019-12-07 Thread Wang Jiefei
Good question, I cannot speak for R's developers but I would like to provide some information on the problem. Here are the first few lines of the dnorm function located at src\nmath\dnorm.c: ``` double dnorm4(double x, double mu, double sigma, int give_log) { #ifdef IEEE_754 if (ISNAN(x) ||

[Rd] What should dnorm(0, 0, -Inf) return?

2019-12-07 Thread Weigand, Stephen D. via R-devel
Hi, Apropos of a recent Inf question, I've previously wondered if dnorm "does the right thing" with dnorm(0, 0, -Inf) which gives zero. Should that be zero or NaN (or NA)? The help says "'sd < 0' is an error and returns 'NaN'" and since -Inf < 0 is TRUE, then... is this a bug? Thank you,