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 1... Line 1...
1
/*
1
/*
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 and Feb, 2001.
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 45... Line 45...
45
    if (p < 0 || p > 1 || n <= 0) ML_ERR_return_NAN;
45
    if (p < 0 || p > 1 || n <= 0) ML_ERR_return_NAN;
46
    R_D_nonint_check(x);
46
    R_D_nonint_check(x);
47
    if (x < 0 || !R_FINITE(x)) return R_D__0;
47
    if (x < 0 || !R_FINITE(x)) return R_D__0;
48
    x = R_D_forceint(x);
48
    x = R_D_forceint(x);
49
 
49
 
50
    prob = dbinom_raw(n-1,n+x-1,p,1-p,give_log);
50
    prob = dbinom_raw(n, x+n, p, 1-p, give_log);
-
 
51
    p = ((double)n)/(n+x);
51
    return((give_log) ? log(p) + prob : p*prob);
52
    return((give_log) ? log(p) + prob : p * prob);
52
}
53
}