Odds of observing numbers in a specific range, given a weighted random number generator

Say I have a weighted random number generator, which generates discrete numbers in a range with a known probability - for example, it generates 1 25% of the time, and 0 the rest.

How do I calculate the odds that I will see k 1's, where k is in the range [a,b], after observing n randomly generated numbers?

• Depends a lot on your distribution. You hint that it is fully discrete. What are the possible outcomes? – jameselmore Mar 17 '15 at 21:23
• i'm not sure what you mean - it's discrete in the sense of it generates only the values 0,1; the expected outcome is the ability to generate a sentence along the lines of: "The odds of seeing anywhere between 200 and 300 1s after observing 1000 randomly generated number are 60%" – blueberryfields Mar 17 '15 at 22:06

Let's call the event of your random number being in the given range a "success". If the random numbers are independent and the probability of success is $p$, then the number $X$ of successes in $n$ trials has a binomial distribution with parameters $n$ and $p$. In particular, $\mathbb P(X=k) = {n \choose k} p^k (1-p)^{n-k}$.