Statistics & probability

Multivariate hypergeometric probability calculator for several colors

Calculate the joint probability of a complete color-count vector when drawing objects uniformly without replacement.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Calculate the joint probability of a complete color-count vector when drawing objects uniformly without replacement. The multivariate hypergeometric model keeps several categories visible at once, returns exact favorable and total subset counts, and gives each color’s feasible marginal range and expected draw count. Decimal conversion is separate from the exact combinatorial arithmetic.

THE FORMULAN=ΣM_j, n=Σk_j; P(K_1=k_1,…,K_c=k_c)=∏C(M_j,k_j)/C(N,n). E[K_j]=nM_j/N; max(0,n−(N−M_j))≤K_j≤min(n,M_j).

A worked example

An urn has five red, four blue and three green objects. Drawing four without replacement, the vector two red, one blue and one green has C(5,2)C(4,1)C(3,1)=120 favorable subsets out of C(12,4)=495 total subsets. Probability is 120/495=8/33≈.24242424. The expected vector is [5/3,4/3,1], which need not be an integer outcome.

Good to know

2–8 color categories, nonnegative integer populations totaling 1–10,000, and aligned nonnegative integer requested counts. Draw size is the sum of the requested counts and must not exceed total population. A request exceeding an individual color population has probability zero. Exact BigInt combinatorial counts; decimal conversion may underflow. Unordered uniform draws without replacement only; no weighted sampling or cumulative region enumeration.

The model counts unordered subsets

Sampling uniformly without replacement makes every subset of n distinct objects equally likely. Colors classify the objects, but objects of one color remain distinct physical choices in the combinatorial count.

The denominator C(N,n) counts all such subsets. Choosing k_j objects from each color produces the numerator product. No ordering multiplier is needed because the same subset is not counted again for every order in which it could have been drawn.

Multivariate hypergeometric probability calculator for several colors worked exampleAn exact count of multicolor drawsPopulation: 5 red + 4 blue + 3 greenRequested draw: 2 red + 1 blue + 1 greenC(5,2) C(4,1) C(3,1)────────────────C(12,4)120 favorable subsets / 495 total subsets = 8/33 ≈ .242424
Scroll across to see the full diagram.
An urn has five red, four blue and three green objects. Drawing four without replacement, the vector two red, one blue and one green has C(5,2)C(4,1)C(3,1)=120 favorable subsets out of C(12,4)=495 total subsets. Probability is 120/495=8/33≈.24242424. The expected vector is [5/3,4/3,1], which need not be an integer outcome.

Compare this with the Hypergeometric probability calculator. A two-category hypergeometric page does not expose a full multicolor count vector.

Enter the whole requested count vector

The requested counts must refer to every color category, and their sum determines the draw size. The page does not silently treat an omitted category as an unrestricted remainder.

A population category may have size zero, which can be useful when retaining a fixed category schema. A positive requested count from that empty category is impossible and gives probability zero. Negative, fractional or mismatched entries are invalid inputs rather than probabilities.

The four-object example by direct counting

With populations [5,4,3], drawing [2,1,1] objects yields ten ways to choose the two red objects, four ways to choose the blue object and three ways to choose the green object. Their product is 120 favorable subsets.

There are 495 four-object subsets of twelve objects in total, so the joint probability is 120/495=8/33. An independent enumeration can label every object individually and count which of those 495 subsets has the requested color composition.

Why separate color probabilities do not multiply

Drawing more objects of one color leaves fewer draw positions for the other colors. The color counts share a fixed total, so they are dependent even though all physical subsets are sampled uniformly.

Multiplying the marginal probability of two reds by the marginal probabilities of one blue and one green ignores this constraint and gives the wrong joint answer. The multivariate formula enforces the full vector in one calculation.

Feasible marginal ranges and expected counts

For color j, no more than min(n,M_j) objects can be drawn. At least max(0,n−(N−M_j)) must be drawn when the other colors do not supply enough objects to fill the sample. These are support bounds, not confidence intervals.

The expected count nM_j/N is an average over all possible draws. In the example, expected red count is five thirds. A fractional expectation is compatible with integer observations and need not equal the most probable complete allocation.

Exact counts and an approximate decimal

Binomial coefficients can become far larger than the largest exactly representable JavaScript number. The prototype uses integer arithmetic for the numerator and denominator, preserving their exact values within the stated population cap.

The displayed probability is converted separately to a floating-point decimal. Very small values may round or underflow, while the exact fraction remains available through its two integer strings. A printed zero decimal should therefore be distinguished from a genuinely impossible event with numerator zero.

Checking the model against the sampling process

Uniform sampling without replacement is the key assumption. Replacement would preserve category proportions after each draw and lead to a multinomial model, while unequal selection chances require a different probability law.

Pooling two colors gives a useful consistency check: summing compatible detailed outcomes should reproduce the coarser hypergeometric probability. The page evaluates one complete vector, so cumulative events such as at least two reds require summing all compatible vectors separately.

A few questions, answered

Does this assume replacement?

No. Objects are drawn uniformly without replacement.

Why is there no order factor?

The equally likely units are unordered subsets; color selection combinations already count them correctly.

Can an expected count be fractional?

Yes. It averages over many integer-valued draws and is not itself required to be an outcome.

Is a decimal zero always impossible?

No. A tiny probability can underflow during decimal conversion. Numerator zero identifies an impossible requested vector.

Find your calculator

Start typing to explore the library.