Balls and Urns Calculator

Model balls, urns, capacities, and occupancy in seconds. Switch between labeled and unlabeled counting modes. Get exact combinatorial totals, then download tidy reports today.

Inputs
Choose a counting model and constraints
Performance cap: n ≤ 350.
Performance cap: k ≤ 120.
Distinct means each ball is unique.
Unlabeled urns count patterns, not labels.
“Not allowed” means all urns must be used.
Applies when urns are unlabeled and empties allowed.
Bounds are supported for unlabeled balls into labeled urns.
Maximum balls per urn.
Minimum balls per urn.

Quick examples
  • Labeled balls → labeled urns: n=10, k=3, empty allowed ⇒ 3^10.
  • Unlabeled balls → labeled urns: n=10, k=3, empty allowed ⇒ C(12,2).
  • Labeled balls → unlabeled urns: n=8, k=3, all nonempty ⇒ S(8,3).
  • Unlabeled balls → unlabeled urns: n=9, k=3, all nonempty ⇒ partitions p(9,3).
Example data table
Scenario n k Model Formula
Functions52Labeled → Labeledk^n
Surjections63Labeled → Labeledk!·S(n,k)
Stars & bars74Unlabeled → LabeledC(n+k-1,k-1)
Partitions83Unlabeled → Unlabeledp(n,k)
Bounded bins103Unlabeled → LabeledIE on bounds
Formula used
What this calculator computes
  • Labeled balls → labeled urns (empty allowed): k^n.
  • Labeled balls → labeled urns (all nonempty): k!·S(n,k).
  • Unlabeled balls → labeled urns (empty allowed): C(n+k-1,k-1).
  • Unlabeled balls → labeled urns (all nonempty): C(n-1,k-1) for n≥k.
  • Unlabeled balls → labeled urns with bounds: inclusion–exclusion for L≤xi≤U and Σxi=n.
  • Labeled balls → unlabeled urns: S(n,k) or Σ S(n,j).
  • Unlabeled balls → unlabeled urns: partitions p(n,k) or summed for “at most”.

Outputs use big integers to avoid overflow.

How to use
Steps
  1. Enter n and k.
  2. Select labeled/unlabeled options for balls and urns.
  3. Choose whether empty urns are allowed.
  4. Optionally set bounds when using unlabeled balls.
  5. Press Compute, then export CSV or PDF.
FAQs
Common questions

1) What does “labeled” mean here?

Labeled means distinguishable. Swapping labels changes the outcome. Unlabeled means only the structure matters, like group sizes or counts.

2) When should I choose “unlabeled urns”?

Choose unlabeled urns when urn identities do not matter. For labeled balls, results follow Stirling numbers. For unlabeled balls, results follow integer partitions.

3) Why does “all nonempty” sometimes give zero?

If every urn must be used but you have fewer balls than urns, it is impossible. Example: n=3, k=5 cannot fill all urns.

4) What are Stirling numbers doing in this tool?

S(n,k) counts partitions of n labeled items into k nonempty unlabeled groups. It also gives surjections to labeled urns via k!·S(n,k).

5) What do the bounds L…U apply to?

Bounds are implemented for unlabeled balls into labeled urns. They count integer solutions to x1+…+xk=n with L≤xi≤U, using inclusion–exclusion.

6) Why are some capacity cases noted as not supported?

Capacity bounds with labeled balls or unlabeled urns often need heavier specialized methods. This version focuses on fast, exact classic families.

7) How can I reuse the result in a report?

Include the model name, the shown formula, and your n and k values. Exported CSV/PDF provides a compact appendix for reproducibility.

Related Calculators

probability combination calculatorbinomial coefficient calculatorpermutation with repetition calculatordouble factorial calculatoranagram calculatorstirling number calculatorpartition number calculatorsubset sum calculatorpermutation formula calculatorcombinatorial probability calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.