Advanced Counting

121 words
1 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Advanced Counting ## Stars and Bars (Combinations with Repetition) Number of ways to distribute $n$ identical objects into $k$ distinct boxes: $$ \binom{n + k - 1}{k - 1} $$ **Example:** Number of solutions to $x_1 + x_2 + x_3 = 10$ with $x_i \geq 0$ integers: $\binom{10+3-1}{3-1} = \binom{12}{2} = 66$. ## Multino...

Advanced Counting

Stars and Bars (Combinations with Repetition)

Number of ways to distribute nn identical objects into kk distinct boxes:
(n+k−1k−1)\binom{n + k - 1}{k - 1}
Example: Number of solutions to x1+x2+x3=10x_1 + x_2 + x_3 = 10 with xi≥0x_i \geq 0 integers: (10+3−13−1)=(122)=66\binom{10+3-1}{3-1} = \binom{12}{2} = 66.

Multinomial Coefficients

(nn1,n2,…,nk)=n!n1!n2!⋯nk!\binom{n}{n_1, n_2, \dots, n_k} = \frac{n!}{n_1! n_2! \cdots n_k!}

Derangements

A derangement is a permutation with no fixed points. Number of derangements of nn items:
Dn=n!∑k=0n(−1)kk!D_n = n! \sum_{k=0}^n \frac{(-1)^k}{k!}
D4=9D_4 = 9, D5=44D_5 = 44, D6=265D_6 = 265.

Catalan Numbers

Cn=1n+1(2nn)C_n = \frac{1}{n+1}\binom{2n}{n}
Counts: balanced parentheses, binary trees, Dyck paths, etc. Join Discord PreviousCounting PrinciplesNextAdvanced Permutations
Document outline

Keep your place and jump directly to a heading.

Table of contents

No note selected

Open a chapter to see its outline, backlinks, and sources here.