In R, is it possible for pbinom to take a noninteger x? I have a homework problem that is asking: "Find the probability that x is within 1 standard deviation of the mean for binomial(n = 20, p = 0.25)".
I found ${\mu} = 5$ and ${\sigma} = 1.94$. So I need to find $P(3.06 < x < 6.94)$. In R, I did pbinom(6.94, 20, .25) - pbinom(3.06, 20, .25) and got 0.561.
How did R compute pbinom when q isn't an integer? I'm confused as to how it's possible to do this when a binomial distribution is discrete.
 A: The function is operating correctly, using the definition of the CDF.  Consider a random variable $X$ with integer support.  For any input $x+r$ with integer part $x$ and remainder $0 \leqslant r < 1$ you should get:
$$F(x+r) \equiv \mathbb{P}(X \leqslant x+r) = \mathbb{P}(X \leqslant x) = F(x).$$
Sure enough, that is exactly what pbinom is doing:
#Check CDF values
identical(pbinom(6.94, 20, .25), pbinom(6, 20, .25))

[1] TRUE

identical(pbinom(3.06, 20, .25), pbinom(3, 20, .25))

[1] TRUE

You can also check that this corresponds to the output of dbinom (to within a small tolerance due to rounding) if you want:
#Check CDF values against PDF values
pbinom(6.94, 20, .25) - sum(dbinom(0:6, 20, .25))

[1] 0

pbinom(3.06, 20, .25) - sum(dbinom(0:3, 20, .25))

[1] 2.775558e-17

A: There are two ways of doing this.

*

*Use a normal approximation to the sampling distribution of the sample mean.

*Round the endpoints to the "closest" integer to get a conservative interval.

You may ask the teacher for clarity if this isn't clearly an application of some methods you've already covered.
EDIT:
Though R provides output for these values, the existence of their result is somewhat of an artifact of using the gamma functional to estimate the combinatorial terms in the expression of the density function. There is but a little "window" of gamma probability around the non-integral values, and relatively steep "steps" in the CDF. Importantly these "windows" and "steep steps" don't correspond to any physical term, nor does it make any practical difference from rounding.


One can try:
set.seed(123)
sim <- rbinom(1e7, 20, 0.25)
mean(3.06 < sim & sim < 6.94)
mean(3 < sim & sim <= 6)

and find

mean(3.06 < sim & sim < 6.94)
1 0.5605642
mean(3 < sim & sim <= 6)
1 0.5605642

similarly:
> pbinom(6.94, 20, 0.25) - pbinom(3.06, 20, 0.25)
[1] 0.5606259
> pbinom(6, 20, 0.25) - pbinom(3, 20, 0.25)
[1] 0.5606259

