The R Project SVN R

Rev

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

Rev 11723 Rev 12976
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, 2001 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 35... Line 35...
35
 
35
 
36
#ifdef IEEE_754
36
#ifdef IEEE_754
37
    if (ISNAN(x) || ISNAN(p)) return x + p;
37
    if (ISNAN(x) || ISNAN(p)) return x + p;
38
#endif
38
#endif
39
 
39
 
40
    if (p <= 0 || p > 1) ML_ERR_return_NAN;
40
    if (p < 0 || p > 1) ML_ERR_return_NAN;
41
 
41
 
42
    R_D_nonint_check(x);
42
    R_D_nonint_check(x);
43
    if (x < 0 || !R_FINITE(x))	return R_D__0;
43
    if (x < 0 || !R_FINITE(x) || p == 0) return R_D__0;
44
    x = R_D_forceint(x);
44
    x = R_D_forceint(x);
45
 
45
 
46
    /* prob = (1-p)^x, stable for small p */
46
    /* prob = (1-p)^x, stable for small p */
47
    prob = dbinom_raw(0.,x, p,1-p, give_log);
47
    prob = dbinom_raw(0.,x, p,1-p, give_log);
48
 
48