The R Project SVN R

Rev

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

Rev 68947 Rev 69128
Line 81... Line 81...
81
    if (K == 1 && p_tot == 0.) return;/* trivial border case: do as rbinom */
81
    if (K == 1 && p_tot == 0.) return;/* trivial border case: do as rbinom */
82
 
82
 
83
    /* Generate the first K-1 obs. via binomials */
83
    /* Generate the first K-1 obs. via binomials */
84
 
84
 
85
    for(k = 0; k < K-1; k++) { /* (p_tot, n) are for "remaining binomial" */
85
    for(k = 0; k < K-1; k++) { /* (p_tot, n) are for "remaining binomial" */
86
	if(prob[k]) {
86
	if(prob[k] != 0.) {
87
	    pp = (double)(prob[k] / p_tot);
87
	    pp = (double)(prob[k] / p_tot);
88
	    /* printf("[%d] %.17f\n", k+1, pp); */
88
	    /* printf("[%d] %.17f\n", k+1, pp); */
89
	    rN[k] = ((pp < 1.) ? (int) rbinom((double) n,  pp) :
89
	    rN[k] = ((pp < 1.) ? (int) rbinom((double) n,  pp) :
90
		     /*>= 1; > 1 happens because of rounding */
90
		     /*>= 1; > 1 happens because of rounding */
91
		     n);
91
		     n);