Displaying 9 results from an estimated 9 matches for "r_d__0".
Did you mean:
r_0_v_0
2019 Dec 08
2
What should dnorm(0, 0, -Inf) return?
...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 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...
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
2000 Feb 25
1
lambda==0 in dpois() (PR#459)
...0
but gives NaNs instead.
Here's a patch to src/nmath/dpois.c that appears to work (although it could ? be more
elegant).
*** dpois.c.orig Fri Feb 25 13:53:06 2000
--- dpois.c Fri Feb 25 14:16:19 2000
***************
*** 35,41 ****
warning("non-integer x = %f", x);
return R_D__0;
}
! if(lambda <= 0.0) ML_ERR_return_NAN;
if (x < 0)
return R_D__0;
--- 35,51 ----
warning("non-integer x = %f", x);
return R_D__0;
}
! if(lambda < 0.0) ML_ERR_return_NAN;
! if(lambda==0.0) {
! if (give_log) {
! if (x==0)...
2019 Dec 09
0
What should dnorm(0, 0, -Inf) return?
...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 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 increme...
2019 Dec 07
0
What should dnorm(0, 0, -Inf) return?
...rmation 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) || 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 docum...
2000 Aug 26
0
Re: [R] too large alpha or beta in dbeta ? (PR#643)
...(fixme) -->> ./gammalims.c */
+
+#else
+ static double xmax = 0; double xmin;
+ if (xmax == 0)
+ gammalims(&xmin, &xmax);
#endif
+
if (a <= 0 || b <= 0) ML_ERR_return_NAN;
if (x < 0 || x > 1)
@@ -35,10 +43,13 @@
if (x < 0 || x > 1)
return R_D__0;
+
+#define R_LOG_DBETA log(x)*(a - 1) + log(1 - x)*(b - 1) - lbeta(a, b)
- if(give_log) {
- return log(x)*(a - 1) + log(1 - x)*(b - 1) - lbeta(a, b);
- }
+ if(give_log)
+ return R_LOG_DBETA;
+ else if (a + b >= xmax) /* beta(a,b) might be = 0 numerically */
+ return exp(R_LOG_DBET...
2000 Aug 28
0
Re: [R] too large alpha or beta in dbeta ? (PR#643)
...(fixme) -->> ./gammalims.c */
+
+#else
+ static double xmax = 0; double xmin;
+ if (xmax == 0)
+ gammalims(&xmin, &xmax);
#endif
+
if (a <= 0 || b <= 0) ML_ERR_return_NAN;
if (x < 0 || x > 1)
@@ -35,10 +43,13 @@
if (x < 0 || x > 1)
return R_D__0;
+
+#define R_LOG_DBETA log(x)*(a - 1) + log(1 - x)*(b - 1) - lbeta(a, b)
- if(give_log) {
- return log(x)*(a - 1) + log(1 - x)*(b - 1) - lbeta(a, b);
- }
+ if(give_log)
+ return R_LOG_DBETA;
+ else if (a + b >= xmax) /* beta(a,b) might be = 0 numerically */
+ return exp(R_LOG_DBET...
2001 Feb 08
2
dnbinom(,size<1,)=0 (PR#842)
This came up on r-help but indicates a bug.
dnbinom(x,n,p) calls dbinom_raw(n-1,...)
which returns 0 for n<1.
-thomas
---------- Forwarded message ----------
Date: Thu, 08 Feb 2001 17:10:23 +0000
From: Yudi Pawitan <yudi@stat.ucc.ie>
To: Mark Myatt <mark@myatt.demon.co.uk>
Cc: R-Help <r-help@stat.math.ethz.ch>
Subject: Re: [R] Goodness of fit to Poisson / NegBinomial
2003 Jul 16
2
Density function for non-central t distribution
...uot;
double dnt(double x, double df, double ncp, int give_log)
{
double u;
#ifdef IEEE_754
if (ISNAN(x) || ISNAN(df))
return x + df;
#endif
// If non-positive df then error
if (df <= 0) ML_ERR_return_NAN;
// If x is infinite then return 0
if(!R_FINITE(x))
return R_D__0;
// If infinite df then the density is identical to a
// normal distribution with mean = ncp
if(!R_FINITE(df))
return dnorm(x, ncp, 1., give_log);
// Consider two cases: x==0 or not
// Do calculations on log scale to stabilize
if (x!=0) {
u = log(df)-log(fabs(x)) +...