The R Project SVN R

Rev

Rev 11723 | 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 54... Line 54...
54
    x = R_D_forceint(x);
54
    x = R_D_forceint(x);
55
    r = R_D_forceint(r);
55
    r = R_D_forceint(r);
56
    b = R_D_forceint(b);
56
    b = R_D_forceint(b);
57
    n = R_D_forceint(n);
57
    n = R_D_forceint(n);
58
 
58
 
-
 
59
    if (n < x || r < x || n - x > b) return(R_D__0);
59
    if (n == 0) return((x == 0) ? R_D__1 : R_D__0);
60
    if (n == 0) return((x == 0) ? R_D__1 : R_D__0);
60
 
61
 
61
    p = ((double)n)/((double)(r+b));
62
    p = ((double)n)/((double)(r+b));
62
    q = ((double)(r+b-n))/((double)(r+b));
63
    q = ((double)(r+b-n))/((double)(r+b));
63
 
64
 
64
    p1 = dbinom_raw(x,r,p,q,give_log);
65
    p1 = dbinom_raw(x,  r, p,q,give_log);
65
    p2 = dbinom_raw(n-x,b,p,q,give_log);
66
    p2 = dbinom_raw(n-x,b, p,q,give_log);
66
    p3 = dbinom_raw(n,r+b,p,q,give_log);
67
    p3 = dbinom_raw(n,r+b, p,q,give_log);
67
 
68
 
68
    return( (give_log) ? p1 + p2 - p3 : p1*p2/p3 );
69
    return( (give_log) ? p1 + p2 - p3 : p1*p2/p3 );
69
}
70
}