Tool to make probabilities on picking/drawing objects (balls, beads, cards, etc.) in a box (bag, drawer, deck, etc.) with and without replacement.
Picking Probabilities - dCode
Tag(s) : Combinatorics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
In combinatorics, random draws are used to study the probabilities of selecting a subset of objects, such as marbles or cards, from a larger set.
Thanks to mathematical models, it is possible to predict how these draws will be distributed without actually performing them. Therefore, there is no need for simulation: the formulas provide precise and accurate results.
For a set of $ N $ objects among which $ m $ are different (distinguishable). The probability of drawing a total of $ n $ objects and that among these $ n $ objects there are $ k $ objects that are part of the $ m $ different ones, is given by a hypergeometric distribution: $$ p(X=k)=\frac{C_{m}^kC_{N-m}^{n-k}}{C_N^n} = \frac{ \binom{m}{k} \binom{N-m}{n-k} }{ \binom{N}{n} } $$
$ C $ represents the combination operator.
Example: Probability to draw $ k=5 $ red card among the $ m=26 $ red cards in a deck of $ N=52 $ cards by drawing $ n=5 $ cards.
Example: Probability to draw all $ k=3 $ black balls in a bowl with $ N=25 $ balls among which $ m=3 $ are black, by picking $ n=3 $ balls.
The probability of never having picked a given item among $ N $ objects after $ n $ random draws is given by the formula $$ \left(1-\frac{1}{N}\right)^n $$
Example: An urn contains $ N = 10 $ balls numbered from 1 to 10. $ n = 5 $ draws are made with replacement. What is the probability of never drawing ball number 7 during the 5 draws?
The probability of having picked at least once a given item among $ N $ objects after $ n $ random draws is given by the formula $$ 1-\left(1-\frac{1}{N}\right)^n $$
Example: A bag contains $ N = 8 $ yellow marbles and $ 12 $ green marbles. What is the probability of drawing at least one yellow marble after $ n = 4 $ draws with replacement?
The probability of having picked all $ N $ objects (discernible or indistinguishable) after $ n $ random draws is given by the formula $$ \sum_{i=0}^N (-1)^{N-i}{\binom{N}{i}}\left(\frac{i}{N}\right)^n $$
Example: A box contains $ N = 4 $ cards of different colors (red, blue, green, yellow). Calculate the probability of having drawn each color of card at least once after $ n = 8 $ draws with replacement.
In a draw with replacement, each draw is completely independent of the others. In other words, the fact that an element has been drawn before has no influence on the probability of it being drawn again. This may seem surprising at first — it's a common mistake among lottery and casino players — but the odds remain exactly the same for each draw.
In contrast, in a draw without replacement, things change: once an element is drawn, it is no longer available for subsequent draws. The probability therefore evolves gradually, as the total number of elements decreases.
dCode retains ownership of the "Picking Probabilities" source code. Any algorithm for the "Picking Probabilities" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Picking Probabilities" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Picking Probabilities" or any other element are not public (except explicit open source licence like Creative Commons). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Picking Probabilities" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source.
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Picking Probabilities on dCode.fr [online website], retrieved on 2025-04-15,