The R Project SVN R

Rev

Rev 11723 | Rev 36820 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11723 Rev 34244
Line 2... Line 2...
2
 *  AUTHOR
2
 *  AUTHOR
3
 *    Catherine Loader, catherine@research.bell-labs.com.
3
 *    Catherine Loader, catherine@research.bell-labs.com.
4
 *    October 23, 2000.
4
 *    October 23, 2000.
5
 *
5
 *
6
 *  Merge in to R:
6
 *  Merge in to R:
7
 *	Copyright (C) 2000, The R Core Development Team
7
 *	Copyright (C) 2000, 2005 The R Core Development Team
8
 *
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
12
 *  (at your option) any later version.
Line 43... Line 43...
43
    if (ISNAN(x) || ISNAN(m) || ISNAN(n))
43
    if (ISNAN(x) || ISNAN(m) || ISNAN(n))
44
	return x + m + n;
44
	return x + m + n;
45
#endif
45
#endif
46
    if (m <= 0 || n <= 0) ML_ERR_return_NAN;
46
    if (m <= 0 || n <= 0) ML_ERR_return_NAN;
47
    if (x <= 0.) return(R_D__0);
47
    if (x <= 0.) return(R_D__0);
-
 
48
    if (!R_FINITE(m) && !R_FINITE(n)) /* both +Inf */
-
 
49
	ML_ERR_return_NAN;
-
 
50
    if (!R_FINITE(n)) /* must be +Inf by now */
-
 
51
	return(dgamma(x, m/2, 2./m, give_log));
-
 
52
    if (m > 1e14) {/* includes +Inf: code below is inaccurate there */
-
 
53
	dens = dgamma(1./x, n/2, 2./n, give_log);
-
 
54
	return give_log ? dens - 2*log(x): dens/(x*x);
-
 
55
    }
48
 
56
 
49
    f = 1./(n+x*m);
57
    f = 1./(n+x*m);
50
    q = n*f;
58
    q = n*f;
51
    p = x*m*f;
59
    p = x*m*f;
52
 
60