Should my curve be monotonic? I'm trying to calculate the probability Pr(X>=x) where X ~ BINOMIAL(N,p1). x is defined by N*p2 (p1, p2 are two assumed proportions)
Below is my R code:
prob <- function(N,p1,p2){
    q <- round(N*p2)
    return(pbinom(q,N,p1,lower.tail = FALSE))
}

Run the function for N=50:300 where p1=0.375, p2=0.25, and plot calculated probability versus sample size. Anyone has an idea why my curve is not monotonic? For example, N=51 has prob. 0.975; N=52 has prob. 0.959.

 A: If both N and x are changing, there's no reason that the associated tail probability $P(X\ge x)$ must be monotonic. It's easy to see that the tail probability increases with N for fixed x, and decreases with x for fixed N. You cannot guarantee this monotonicity if both N and x are allowed to change, even if both of these are increasing.
As a fun illustration of this, run your code with p1 = p2 = 0.5. You'll observe waves in the tail probability:
N= 1  q= 0  prob= 0.5 
N= 2  q= 1  prob= 0.25 
N= 3  q= 2  prob= 0.125 
N= 4  q= 2  prob= 0.3125 
N= 5  q= 2  prob= 0.5 
N= 6  q= 3  prob= 0.34375 
N= 7  q= 4  prob= 0.2265625 
N= 8  q= 4  prob= 0.3632813 
N= 9  q= 4  prob= 0.5 
N= 10  q= 5  prob= 0.3769531 
N= 11  q= 6  prob= 0.2744141 
N= 12  q= 6  prob= 0.387207 
N= 13  q= 6  prob= 0.5 
N= 14  q= 7  prob= 0.3952637 
N= 15  q= 8  prob= 0.3036194 
N= 16  q= 8  prob= 0.4018097 
N= 17  q= 8  prob= 0.5 
N= 18  q= 9  prob= 0.4072647 
N= 19  q= 10  prob= 0.3238029 
N= 20  q= 10  prob= 0.4119015 

Notice that when q remains constant, the tail probability increases with N. But when both N and q increment by one, the tail probability cannot increase. This is necessarily true, because to observe at least q+1 successes in N+1 tosses it must be the case that you saw at least q successes in the first N tosses.
