Displaying 7 results from an estimated 7 matches for "ml_posinf".
2019 Dec 08
2
What should dnorm(0, 0, -Inf) return?
...ML_ERR_return_NAN;
but surely negative sd should always be an error?
I'd be inclined to do
if (sigma < 0) ML_ERR_return_NAN;
if(!R_FINITE(sigma)) return R_D__0;
if(!R_FINITE(x) && mu == x) return ML_NAN;/* x-mu is NaN */
if (sigma == 0)
return (x == mu) ? ML_POSINF : R_D__0;
x = (x - mu) / sigma;
(Ping Martin...)
-pd
> On 7 Dec 2019, at 23:40 , Wang Jiefei <szwjf08 at gmail.com> wrote:
>
> 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...
2005 Aug 09
0
qpois minor bug (PR#8058)
...Functions' pages
935 and 928
Mikael
double qpois(double p, double lambda, int lower_tail, int log_p)
{
double mu, sigma, gamma, z, y;
#ifdef IEEE_754
if (ISNAN(p) || ISNAN(lambda))
return p + lambda;
#endif
if(!R_FINITE(lambda))
ML_ERR_return_NAN;
R_Q_P01_boundaries(p, 0, ML_POSINF);
if(lambda < 0) ML_ERR_return_NAN;
if(lambda == 0) return 0;
mu = lambda;
sigma = sqrt(lambda);
gamma = sigma;
/* Note : "same" code in qpois.c, qbinom.c, qnbinom.c --
* FIXME: This is far from optimal [cancellation for p ~= 1, etc]: */
if(!lower_ta...
2002 Oct 17
1
underflow handling in besselK (PR#2179)
...If this is appropriate, the following patch should do the job:
*** bessel_k.c Thu Oct 17 13:55:55 2002
--- bessel_k.c.dist Thu Oct 17 13:48:53 2002
***************
*** 216,224 ****
ML_ERROR(ME_RANGE);
*ncalc = *nb;
for(i=0; i < *nb; i++)
! if (ex<=0)
! bk[i] = ML_POSINF;
! else bk[i]=0.0;
return;
}
k = 0;
--- 216,222 ----
ML_ERROR(ME_RANGE);
*ncalc = *nb;
for(i=0; i < *nb; i++)
! bk[i] = ML_POSINF;
return;
}
k = 0;
(By the way, the test for x<=0 seems inappropriate; it looks like x<0 is
caught...
2019 Dec 07
2
What should dnorm(0, 0, -Inf) return?
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,
Stephen
Rochester, MN USA
2019 Dec 09
0
What should dnorm(0, 0, -Inf) return?
...egative sd should always be an error?
> I'd be inclined to do
> if (sigma < 0) ML_ERR_return_NAN;
> if(!R_FINITE(sigma)) return R_D__0;
> if(!R_FINITE(x) && mu == x) return ML_NAN;/* x-mu is NaN */
> if (sigma == 0)
> return (x == mu) ? ML_POSINF : R_D__0;
> x = (x - mu) / sigma;
> (Ping Martin...)
I think you are spot on, Peter.
All of this code has a longish history, with incremental border
case improvements.
Let's hope (somewhat unrealistically) this is the last one for
dnorm().
NB: dlnorm() and some of the gamma/ch...
2019 Dec 07
0
What should dnorm(0, 0, -Inf) return?
...(ISNAN(x) || ISNAN(mu) || ISNAN(sigma))
return x + mu + sigma;
#endif
if(!R_FINITE(sigma)) return R_D__0;
if(!R_FINITE(x) && mu == x) return ML_NAN;/* x-mu is NaN */
if (sigma <= 0) {
if (sigma < 0) ML_ERR_return_NAN;
/* sigma == 0 */
return (x == mu) ? ML_POSINF : R_D__0;
}
....
}
```
You can clearly see where the problem is. I think either the document or
the code needs a modification.
Best,
Jiefei
On Sat, Dec 7, 2019 at 5:05 PM Weigand, Stephen D. via R-devel <
r-devel at r-project.org> wrote:
> Hi,
> Apropos of a recent Inf quest...
2005 Apr 07
0
R 2.1.0 (beta) on IRIX
...ved by removing the R_INLINE keyword. I can't see
another solution, and reading these guidelines on inlining
( http://www.greenend.org.uk/rjk/2003/03/inline.html ) leaves me no
wiser.
2) IEEE arithmetic
The standalone math library fails to compile, as the compiler chokes on
the definition of ML_POSINF, ML_NEGINF and ML_NAN, e.g.
> cc-1195 cc: ERROR File = mlutils.c, Line = 130
> The indicated floating-point operation result is out of range.
>
> double NA_REAL = ML_NAN;
where ML_NAN is defined as (0.0 / 0.0) in nmath.h. The compiler flag
-OPT:IEEE_NaN_inf=ON is supposed to e...