Displaying 11 results from an estimated 11 matches for "give_log".
2003 Jul 16
2
Density function for non-central t distribution
...f(0, df, ncp) = exp(-.5*ncp^2) / (sqrt(pi)*sqrt(df)*gamma(df/2))*gamma((df+1)/2)
*
* is used for x=0.
*
* All calculations are done on log-scale to increase stability.
*
*/
#include "nmath.h"
#include "dpq.h"
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 t...
2001 Feb 09
0
Re: [Rd] dnbinom(,size<1,)=0 (PR#842)
my current code for dnbinom.c has
prob = dbinom_raw(n,x+n,p,1-p,give_log);
f = ((double)n)/((double)(n+x));
return((give_log) ? log(f) + prob : f*prob);
which should work for x>=0, n>=0, 0<=p<=1.
dbinom.raw(x,n,p) is intended to work for x>=0, n>=0, 0<=p<=1,
without integer checks. When necessary (ie. for x in the dnbinom case)
the checks sh...
2000 Aug 26
0
Re: [R] too large alpha or beta in dbeta ? (PR#643)
...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_DBETA);
else {
double y;
y = beta(a, b);
------
Martin Maechler <maechler@stat.math...
2000 Aug 28
0
Re: [R] too large alpha or beta in dbeta ? (PR#643)
...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_DBETA);
else {
double y;
y = beta(a, b);
------
Martin Maechler <maechler@stat.math...
2019 Dec 08
2
What should dnorm(0, 0, -Inf) return?
...gt; 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 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_E...
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
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
2019 Dec 07
0
What should dnorm(0, 0, -Inf) return?
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) || 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 */...
2004 Oct 06
1
dlogis for large negative numbers
Hi to all,
> dlogis(-2000)
[1] NaN
Warning message:
NaNs produced in: dlogis(x, location, scale, log)
> dnorm(-2000)
[1] 0
Is this an expected behaviour of `dlogis()'?
Thanks in advance for any comments,
Dimitris
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 1
minor 9.1
2000 Feb 25
1
lambda==0 in dpois() (PR#459)
...= %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) return 0.0;
! else ML_ERR_return_NAN;
! }
! else {
! if (x==0) return 1.0;
! else return 0.0;
! }
! }
if (x < 0)
return R_D__0;
--please do not edit the information below--
Version:
platform = i686-un...
2019 Dec 09
0
What should dnorm(0, 0, -Inf) return?
...annot 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) || 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 */
>>...