Sie sind auf Seite 1von 75

ANALYTIC COMBINATORICS

PART TWO

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

3. Combinatorial Parameters

and MGFs

http://ac.cs.princeton.edu

Analytic combinatorics overview

A. SYMBOLIC METHOD

1. OGFs

2. EGFs

3. MGFs

B. COMPLEX ASYMPTOTICS

SYMBOLIC METHOD

specification

4. Rational & Meromorphic

5. Applications of R&M

6. Singularity Analysis

7. Applications of SA

8. Saddle point

Analytic

Combinatorics
Philippe Flajolet and
Robert Sedgewick

GF

equation

ANALYTIC COMBINATORICS

PART TWO

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

3. Combinatorial parameters and MGFs

• Basics

^Moment calculations
f©BGF examples

• Labelled classes

http://ac.cs.princeton.edu

II.3a.MGFs.Basics

Natural questions about combinatorial parameters


What is the average number
of subsets in a random

set partition ?

What is the average number


of cycles in a random

permutation ?

What is the average number


of pacts in a random

composition ?

What is the average


number of pacts in a
random partition ?

What is the average coot


degcee of a random tree ?

What is the average number


of times each lettec appeacs
in a random M-word ?

What is the average number


of leaves in a random tree ?

Natural questions about combinatorial parameters

Problem: Average-case results are sometime easy to derive but unsatisfying.

Example. Separate chaining hashing randomly assigns N keys to M lists.

Q. Average length of a list ?


A. N/M. < -

A trivial result that is not very useful because it


says nothing about the length of a particular list.

Ex: All the keys could be on one list.


Avg. length = (N + 0 + 0 + ... + 0 )/M = N/M

Section S.4

Solution: Find distribution (probability parameter value is k for all k )

Practical compromises. Ex: B 0unc j probability that list length deviates


significantly from average,

•compute average and variance

•compute average extrema! values * Ex: Compute average length of the longest list.

Goals for this lecture: Learn enough about parameters to be able to


•compute full distribution (in principle)

•compute moments and extremal values (in practice)

Natural questions about combinatorial parameters

How many ways to partition


a set of N objects
into k subsets?

How many permutations of

size N have k cycles?

How many compositions

(sequences of positive integers


that sum to N ) have k parts?

How many partitions (sets


of positive integers that
sum to N ) have k parts?

How many trees with N


nodes have root degree k ?

How many letters


appear k times in an
M-word of length N ?
How many trees with N
nodes have k leaves ?

Basic definitions (combinatorial parameters for unlabelled classes)

Def. A combinatorial class is a set of combinatorial objects and an associated size


function that may have an associated parameter.

Def. The ordinary bivariate generating function (OBGF)


associated with a class is the formal power series

a(z,u) = z \ a \ u c ° st (A

size function

object name

a<EA

S v

parameter value

class name

Fundamental (elementary) identity

A(z) = z \ a \u cost ( a ) — y~^/\ N ^z N g /c

aeA N>0k>0

Terminology.

The variable z marks size

The variable u marks the parameter

Q. Flow many objects of size N with value k?

A. A Nk = [z N ][u k ]A(z,u)
Terminology.

BCF: bivariate CF.


MGF: multivariate GF

might add arbitrary


number of markers

With the symbolic method, we specify the class and at the same time characterize
the OBGF

Combinatorial enumeration: classic example

Q. How many binary strings with N bits?

£>i=2

0 0
0 1
1 0
1 1

£2 = 4

A. Bn= 2"

0 0 0
0 0 1
0 10
Oil
10 0
10 1
110
111

B 3 = 8

0 0 0 0
0 0 0 1
0 0 10
0 0 11
0 10 0
0 10 1
0 110
0 111
10 0 0
10 0 1
10 10
10 11
110 0
110 1
1110
1111

£ 4 =16

Combinatorial parameters: classic example

Q. How many A/-bit binary strings have k 0 bits?

fiio = 1
fin = 1

0 0
0 1
1 0
1 1

fi 2 o= 1
fi 2 i = 2
fi22= 1

A ' e “ = C)

0 0 0
0 0 1
0 10
Oil
10 0
10 1
110
111

fi30= 1

fisi = 3
fi32 = 3
fi33= 1
0 0

0 0

0 0

0 0

0 1

0 1

0 1

0 1

1 0

1 0

0
1

1 0

1 0

1 1

1 1

1 1

1 1

fi40

fi41

fi42

fi43
=

fi43

OBGF of binomial coefficients

= V(1 +u) N z N

N> 0

= E

k>0

(1 - z) k +'

(horizontal OGF)

(vertical OGF)

1 - z(1 + u)

(OBGF)

horizontal OGF
coefficients

N k '

0
1

■[u k ](1 + u) 7 =

10

The symbolic method for OBGFs (basic constructs)

Suppose that A and B are classes of unlabelled objects with OBCFs A(z,u) and B(z,u)
where z marks size and u marks a parameter value. Then

operation

notation

semantics

OGF

disjoint union

A + B

disjoint copies of objects from A and B

A(z, u ) + B(z , u )

Cartesian product
A x B

ordered pairs of copies of objects,


one from A and one from B

A(z, u)B(z, u )

sequence

SEQ(A)

sequences of objects from A

1 — A(z, u )

Construction immediately gives OBGF equation, as for enumeration.

Extends immediately to mark multiple parameters simultaneously with MGFs.

Proofs of correspondences

Ax B

SEQ(A)

A + B

z \c\ u cost(c)

c<EA+B

z l a li/ cosf ( a ) 4 z |6| a cost(b) — ^( Zj ^ _|_ b (^ z ^ ^

aeA beB

cEaxb

-Jc| yCOSt(c)

|a| + |b| yCost(a)+cost(b )

E
z \a\ u c °st(a)\

aEA b(E.B

aG/\ b(zB

A(z , u)B(z , a)

z |b| a cost(b)^

construction OCF

5£Q t (A) = A k

A(z,u) k

SEQ t (A) = A u + /\ f2 + /\ t3 + ...

where T = ti, t 2 , t 3 ,... is a subset of the integers

A(z , tv/ 1 + /A(z, i/) t2 4 /\(z, tv/ 3 4 ...

5£Q(A) = e + /\+A 2 +/\ 3 + ...

i +a( Z’ u ) +a (Z’ 4 + ---- 1 _ a(ZjU)

Combinatorial parameter example: 0 bits in bitstrings

Class B, the class of all binary strings


Size \b\, the number of bits in b

Parameter zeros(b), the number of 0 bits in b

OBCF B ( Z > U ) = Y1 Z |b| u zer0s(b) = B NkZ N U k

beB N>0k>0

Construction

OBGF equation

variable u “marks” the parameter


1

B = SEQ (uZo + Zi)

Expansion

B Nk = [u k }[z N ]B(z,u) = [u k ](1 +u) N = [z N ]

(1 -z) k +'

ANALYTIC COMBINATORICS

PART TWO

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

3. Combinatorial parameters and MGFs

• Basics

^Moment calculations
f©BGF examples

• Labelled classes

http://ac.cs.princeton.edu

II.3a.MGFs.Basics

ANALYTIC COMBINATORICS

PART TWO
Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

3. Combinatorial parameters and MGFs

• Moment calculations

f^©BGF examples

• Labelled classes

CAMBRIDGE

http://ac.cs.princeton.edu

II.3b.MGFs.Moments

OBGF moment calculations

OBGF

P(z,u) = E z

size function

\p\ u cost(p)

object name

pEP

S' X

parameter value

^>") = EE PNkU k z N
N> 0 k >0

class name

Enumeration

P n = \z n ]P{z, 1) P(z, 1 ) = E z ' Pl

pev

number of objects of size N

PN = ^2pNk P(Z, 1)
k>0

total cost in objects


of size N

du

Mean cost of objects of size N Pn

[z N ]Pu(z, 1) Q

[z N ]P(z, 1) Pn
2 [z N ]Puu(z, 1 )

[z«]P(z,1)

+ Pn — P/v

E^ n = EEp^ n

N>0

N >0 Jt>0
Cumulated cost

Q n = [z N ]P„(z, 1) p„(z,1) = Ecost(p)z'Pl Q N = J2 k p Nk P„(z,1)


t pGP /c>0

dP(z , u)

( 7=1

Eq« zN = EE ><PNkZ N

N> 0

N>0k>0

Pn

= E

Pn/c

k>0

= E^-m :

k>0

Variance

Moments for 0 bits in bitstrings with OBGFs

Class
B, the class of all binary strings

Example

10111010001000

Size

\b\, the number of bits in b

OBCF

B{z,u) = ^ z l b\ u zeros(b)

Parameter

zeros(b), the number of 0 bits in b

beB

Construction
OBGF equation
Enumeration

Cumulated cost

Mean cost of objects of size N

B = SEQ (wZo +Z\)

B(z,u)

1 - z(1 + u)

[z N ]6(z,1) = [z N ] r i^

= 2

[z N ]^(z,1) = [z N ]

N 1

0 -2z)2
N2

N—1

[z N ]^(z,1)

B u (z,u)

(1 -z-zu) 2

Variance

(easier with horizontal GFs: stay tuned)

17

"Horizontal" and "vertical" OGFs

Y Y PNkZ N U k

N> 0 k>0

= p^(u)z N {horizontal OGF)

N> 0

— q/ c (z)a /c {vertical OGF)

k>0

horizontal OGF
coefficients

A/ ^0123456789

\
0

vertical OGF
coefficients

PS7

<-

MMu)

[z^lqsfz)

18
Moment calculations ("horizontal" OGF)

OBGF.

p( z ,u) = Y^ z

size function

\p\ u cost(p)

peP

s* \

object name class name

parameter value

GF for costs of objects


of size N

"Horizontal" OGF

Enumeration

Cumulated cost

Mean cost of objects of size N

[z N ]P(u,z) = p N (u) = Y u cosf(p)

pEP and size(p)=N

Pn( i)= 1 =p

PEVn

PnO) = E cost (p) = Q

PEVn
Hn

PnO) _ Q
Pn( i) p.

a N —

pM

Pn{ 1)

+ pN ~ PN^

p N kU k z N

N> 0 k>0

Pn(u) = YP NkLjk

k>0

Pn( 1) = Y,P Nk =
k>0

p'nO) = Y k P Nk =

k>0

Variance

0 bits in bitstrings with a "horizontal" OGF

OBGF

B(z,u) = , /'ll \
1 — z(1 + U)

"Horizontal" OGF

b N (u) = [z n ]B(z, u) = (1 + u) N

Enumeration

M 1)=2 N

Cumulated cost

6^(1) = N2 n “ 1

Average # 1-bits in a
random N-b\t string

*n( 1)/M1) = /V2 n_1 /2 n =(N/2) /

Variance

6"(1 )/b N (1) + N/2 - (N/2) 2 = N/4

concentrated: a n — VN/2 (stay tuned)

20

Moment calculations ("vertical" OGF)

OBGF.

p( z ,u) = E z

size function

\p\ u cost(p)

object name

pEP

S' V

parameter value
class name

GF for costs of objects


of cost k

^) = EE PNkU k Z N

N> 0 k >0

"Vertical" OGF

Enumeration

Cumulated cost.

[u K \P(u,z) = q k {z) = Y, z ' Pl

pEP and cost(p)=k

P N = [z N ]P(z , 1)

[ Z N iE%( z ) = Qn

Mean cost of objects of size N

Pn —

P,

q k (z) = Y,PNkZ N

N> 0

E%w = EE !<PNkZ N
k N> 0

= E(EW) zN

N> 0 k \

Qn

E kpnk

k>0

Variance

(omitted)

21

0 bits in bitstrings with a "vertical" OGF

OBGF

"Vertical" OGF

Enumeration

Cumulated cost

B(z,u)

1 -z( 1 +tv)

q k (z) = [u k ]B(z, u) =

z
(1 -z) k +'

P n = [z n ]B{z, 1) = 2 n

Average # 1-bits in a
random A/-bit string

= N2 n ~'

Pn/Qn =(n}2) /

^Tkr k ~i

yk

V/, z _

/ 1 _ -7^+1 /"I _ -r \2

(1 -r)

Z E*;

Jc-1

t 0-z)*+’ (1 -z) 2 ^-(i -z;

k -1

(1 -z) 2 0 -T^l) 2

(1 -2z)2

22
Moment inequalities and concentration

Let Xn be the value of a parameter for a random object of size N with mean p/v and
std dev cjn.

Markov inequality. Pr{X^ > < 1 ft

Chebyshev inequality. Pr{|X^ — /i N \ > ta^} < /t 2

“The probability of being much larger


than the mean must decay, and an upper
bound on the rate of decay is measured
in units given by the standard deviation.”

Def. A distribution is concentrated if on — o(/^n).

Proposition. If a distribution is concentrated,

then 1 in probability: lim Pr{1

N—7-00

e <

Xn_

flN

< 1 +e} = 1

When a distribution is concentrated, the expected value is “typical”.


Example: 100,000,000 random bits

Expected # 1 bits N/2 50,000,000

Standard deviation \fN/2 5,000

Probability X/v is between 49,900,000 and 50,100,000 .9975

23
Moments for letters in M-words with OBGFs

Class

Wm, the class of all M-words

Example

Size

|w|, the number of letters in w

OBGF

Parameter

occ{w), # of occurrences of a given letter in w

43552411

W M (z,u) = ^ 2

w£ W M

Construction

OBGF equation

Enumeration

Cumulated cost

Mean # of occurences of a
given letter in a random
M-word with N letters

Variance

B = SEQ (uZ + (M- 1)Z)


W M (z,u)

[z N ]l/l/(z, 1) = [z N ]

1 - (M- 1 +u)z

N-i

1 — Mz

[z N ]W u (z, 1) = [z™]

N-\

(1 - Mz) 2

= NM

•N -1

Bn —

[z N ]W u ( z,1)
[z N ]W(z, 1)

2 r ^Ni W uty (z, 1) 2 Kil\/i2

° z n = [n

[z N ]W(z, 1)

+ BN - Bn = N / M - N/M 2
[z N ]W u (z } 1)
[z N ]W uu (z, 1)

2 3

.|w| ^occ(w)

N(N- 1)/V/ N “ 2

Standard deviation

a N = - N/M 2

concentrated for fixed M

24

Application: Hashing algorithms

Goal: Provide efficient ways to

• Insert key-value pairs in a symbol table .

• Search the table for the pair corresponding to a given key.

Algorithms

The Art of
Computer
Programming

Sorting and Searching


Second Edition
DONALD E. KNUTH

Strategy

• Develop a hash function that maps each


key into value between 0 and M- 1.

• Maintain M lists of key-value pairs

Q. Average list length for N keys?

A. N/M < -Trivial

Q. Typical list length for N keys, for fixed IVR


A. N/M, concentrated «-Useful

key hash a

S 2 0

E 0

A 0 2

R 4
C 4
H 4
E 0
X 2
A 0
M 4
P 3
L 3

E 0 12

25
ANALYTIC COMBINATORICS

PART TWO

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

3. Combinatorial parameters and MGFs

• Moment calculations

f^©BGF examples

• Labelled classes

CAMBRIDGE

http://ac.cs.princeton.edu

II.3b.MGFs.Moments

ANALYTIC COMBINATORICS

PART TWO

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

3. Combinatorial parameters and MGFs


^Moment calculations

• OBGF examples

• Labelled classes

CAMBRIDGE

http://ac.cs.princeton.edu

II.3c.MGFs.0BGFs

Number of parts in compositions

Q. How many compositions of N have k parts?

1 + 1

1 + 1+1
1 + 2

2 + 1

C 21 = 1

C 22 = 1

C 31 = 1

cumulated cost: 3
average: 1.5

C 32 = 2
C 33 = 1

cumulated cost: 8
average: 2

(ro

1 + 1 + 1 + 1
1 + 1 + 2

1 + 2 + 1

1+3
2 + 1+1
2 + 2

3 + 1

C 4 1 = 1
Caz = 3
C 43 = 3
C 4 4 = 1

cumulated cost: 20
average: 2.5

C41 + 2C42 + 3C43 +4C44 = 20

l+l+l+l + l
1 + 1 + 1 + 2

1 + 1 + 2 + 1

1 + 1+3

1 + 2 + 1 + 1
1 + 2 + 2
1+3 + 1

1 + 4

2 + 1 + 1 + 1

2 + 1 + 2

2 + 2 + 1

2 + 3

3 + 1 + 1

3 + 2

4 + 1

C51 = 1
C52 = 4
C53 = 6

C54 = 4
C55 = 1
cumulated cost: 48
average: 3

Number of parts in compositions

Class

C, the class of all compositions

Example

1+3 + 1+ 5 + 2 = 12

Size

|c|, the number of «s in c

• 1 ••• 1 • 1 ••••• | •• - ••••••••••••••••

C(z,u) = ^z |c| u pa ' ts( c)


cec

Parameter

parts(c), the number of parts in c

OBCF

Construction

OBGF equation from symbolic method

"Horizontal" OGF for parts in a composition of N

Enumeration
Cumulated cost

C(z, u ) =

C = SEQ ( u SEQ> 0 (Z))

1 1 -z

1 — u

1 -z

1 — z(u + 1)
Qv(tv) = [z N ]C(z, a) = (u + 1 ) N — (u + 1 ) N_1
c/v(1) = 2 N — 2 n_1 = 2 n_1
c^(1) = N2 n_1 - (N - 1 )2 n_2 = (N + 1 )2 n “ 2

Average # parts in a random composition of W

c n(1 )/ c n(1 )

29

Tree parameters

Q. What is the expected root degree of a random tree with N nodes ?


Q. How many leaves in a random tree with N nodes ?

30

Leaves in a random tree

Q. How many leaves in a random tree with N nodes ?

31

Leaves in random trees

Q. How many trees with N nodes and k leaves ?

•i :

<7-10=1 <7-21 = 1
O 31 = 1 ?

Ch 2=1 °

cumulated cost: 3 X

average: 1.5

0 - 4 1 = 1
042 = 3
043 = 1

A. N/2 (next slide)

cumulated cost: 1 0
average: 2

A A A

l IA

a 5] = i

052 = 3

Oss = 6

O 54 = 1

cumulated cost: 35
average: 2.5

32
Leaves in random trees

Class C, the class of all ordered trees

Size \g\, the number of «s in g

Parameter leaves(g), the number of leaves in g

OBGF

Construction

OBGF equation from symbolic method

Enumeration OGF

Cumulated cost OGF

Average # leaves in a random tree

G L = uZ+ZxSEQ> 0 ( G L )

~ L , x zG [ (z, u)

C (z,u) = zu + 1 _ G t (Z;0)

C L {z, 1) = C(z)

c " (z ’ 1) = f (1 + 7rbl

[z N ]C[,(z, 1) /N

[z N ]C(z) = -

1 f2N — 2"

[z N ]

v/1 -4z
N V N- 1

[z N ]C(z) =^2 lf ° rW>2/

^concentrated: o/v is O(VN)

33

Root degree in random trees

Q. How many trees with N nodes and root degree k ?

•i :

C D io = 0 C D 21 = 1

C D 31 = 1 J

C D 32=1 °

cumulated cost: 3 X

average: 1.5

C°4 i = 2
C°42 = 2
C D 4B = 1

A. (next slide)

cumulated cost: 9
average: 1.8

A A A

l IA

A
C D si = 5
C D 52 = 5
Cd 53 = 3

C D 54 = 1

cumulated cost: 28
average: 2

34

Root degree in random trees

Class

Size

C, the class of all ordered trees


\g\, the number of «s in g

Parameter deg(g), the degree of the root of g

OBCF

Example

C L (z, u) =

gee
Construction

G D = Z x SEQ> 0 ( uG D )

N 3

N + 1

OBGF equation from symbolic method

Enumeration OGF

Cumulated cost OGF

Average # leaves in a random tree

C D (z, u)

1 — uG{z)

C D (z, 1) =
C D u {z, 1) = -

C(z)

zC{z)

— G(z)) 2

(1

1
1.5

1.8

2 /

[z N ]C„ (z, 1) G n+1


[z N ]C(z) C N

- 1

wTtQ = 2N(2N-\)N

b CnZ) (N+1)NN

N+ 1

35

Rhyming schemes

Q. How many ways to rhyme a poem ?

There was a small boy of Quebec A


Who was buried in snow to his neck A
When they said, "Are you friz?" B
He replied, " Yes, I is — B

But we don't call this cold in Quebec! A

TWO roads diverged in a yellow wood, A


And sorry I could not travel both B
And be one traveler, long I stood A
And looked down one as far as I could A
To where it bent in the undergrowth; B

36
Rhyming schemes

Q. How many ways to rhyme an N-line poem with k rhymes ?

Si i = 1

A B
A A

521 = 1

522 = 1

ABC
ABB
ABA
A A B
AAA

531 = 1

5 32 = 3
S3 3 = 1

A B C D

A B C C

A B C B

A B B C

A B C A

ABAC

A A B C

A A B B

A B A B

ABBA

A B B B

A B A A

A A B A S 4 i = 1
A A A B *2 = 7

A A A A *3 = 6

*4= 1

37

Rhyming schemes

Class

S, the class of all rhyming patterns

Example

ABCADABE

Size

number of lines

Parameter

number of rhymes with k lines

OBCF

S(Z,U) = ^ z l s\ u rhymes(s)

ses

"Vertical" construction Za x SEQ ( Za) x Zb x SEQ ( Za + Zb) x Zc x SEQ ( Za + Zb +


Zc) x ...

Vertical OGF

5/c(z)

(1 — z)(1 — 2z)... (1 — kz)

"Stirling numbers of the 2nd kind " (stay tuned)


-yN. .k

Z U ~

/c!

Average # /(-rhyming patterns in an AMine poem

N>0 ^>0

details omitted
(see page 63)

OBGF of Stirling numbers of the 2nd kind (partition numbers)

N>0k >0

z N u k

= Bn

r N

N> 0

(horizontal OGF)
"Bell polynomials"

N k -

= E

k>0

(1 — z)( 1 — 2z)... (1 — kz)


U (vertical OGF)

vertical OGF
coefficients

1 I

3 1

horizontal OGF
coefficients

-*-

15

25

10

1
31

90

65

15

63

301

350

140

[u k ]B 4 (u)

21 1

(1 -z)(1 — 2z)(1 — 3z)

39

ANALYTIC COMBINATORICS

PART TWO

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

3. Combinatorial parameters and MGFs


^Moment calculations

• OBGF examples

• Labelled classes

CAMBRIDGE

http://ac.cs.princeton.edu

II.3c.MGFs.0BGFs

ANALYTIC COMBINATORICS

PART TWO

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

3. Combinatorial parameters and MGFs

^Moment calculations

f^GBGF examples

• Labelled classes

CAMBRIDGE

http://ac.cs.princeton.edu

II.3d.MGFs.EBGFs

Basic definitions (combinatorial parameters for labelled classes)

Def. A labelled combinatorial class is a set of labelled combinatorial objects and


an associated
size function that may have an associated parameter.

Def. The exponential bivariate generating function (EBGF)


associated with a labelled class is the power series A(z, u )

object name

size function

z 1

cost(a)

a£A

S' v

a || parameter value

class name

Fundamental (elementary) identity

Mz,u) = J2

aeA

yCost(a)

E E w zN “ k

N>0k >0

Terminology.

The variable z marks size

The variable u marks the parameter


Q. How many objects of size N with value k ?

A. A Nk = N\[z N ][u k ]A(z,u)

Terminology.

BCF: bivariate CF.


MGF: multivariate GF

might add arbitrary


number of markers

With the symbolic method, we specify the class and at the same time characterize
the EBGF

42

The symbolic method for BGFs (basic constructs)

Suppose that A and B are classes of unlabelled objects with EBCFs A(z,u) and B(z,u)
where z marks size and u marks a parameter value. Then

operation

notation

semantics

OGF

disjoint union

A + B

disjoint copies of objects from A and B

A(z, u ) + B(z , u )

labelled product

A* B

ordered pairs of copies of objects,


one from A and one from B

A(z, u)B(z, u )

sequence
SEQ(A)

sequences of objects from A

1 — A(z, u )

Construction immediately gives BGF equation, as for enumeration.

Extends immediately to mark multiple parameters simultaneously with MGFs.

43

Number of different letters in 3-words

Q. How many different letters in a 3-word of length N ?

3 Wu = 3

cumulated cost: 3
average: 1.5

1 1
1 2

1 3

2 1
2 2

2 3

3 1

32 W21 = 3

33 I/I/2 2 = 6

cumulated cost: 1 5

average: 1.667

111 211
112 2 12

113 2 13
12 1 2 2 1

1 2 2 2 2 2

1 2 3 2 2 3

13 1 2 3 1

1 3 2 2 3 2

1 3 3 2 3 3

3 11
3 12
3 13
3 2 1
3 2 2
3 2 3
3 3 1
3 3 2
3 3 3

cumulated cost: 57

average: 2.111

14/bi = 3

H/32 = 1 8

W33 = 6

44

Number of different letters in M-words

Class

Wm, the class of all M -words

Example

314641223441

Size

\w\, the length of w

y\w\
W M (z,u)= V

kv !

wE Wm

Parameter

lets(w), the # of different letters in w

EBGF

Construction

Wm = SEQm (E+ u SET>o(Z) )

EBGF equation from symbolic method

W M (u,z) = (1 + u(e z - 1))

Enumeration EGF

Cumulated cost EGF

W M (1,z) = e

zM

W 0 (1,z) = Me z(M "'>(e z - 1) = Me zM - Me

z(M- 1)

,»- 'SSSrn =^(. - (. - bn

N![z N ] W(1, z)

N mn

2
B

1.667

2.111

Average # different letters in


a random M -word of length A/

45

Number of different letters with a given frequency in M-words

Class

Wm, the class of all M -words

Example

314641223441

Size

| w\, the length of w

7 m

W M (z,u)= T -^u 4(w)

^ \w !

W(E W/v;

Parameter

fk(w), the # of different letters in w

EBGF

Construction
EBGF equation from symbolic method

Enumeration EGF

Cumulated cost EGF

Average # letters that appear k times


in a random M-word of length N

Wm = SEQm ( SET±k ( Z) + u SETk(Z) )

W M (u,z) = (e z + (u -

W M 0,z) = e zM

7 k

W u (1,z) = Me z(M_1) —

k\

/V![z N ]lV u (1,z) (N\ l_ k _


N![z N ]W(1,z) 1 M 1

occupancy /■
distribution y

46

Cycles in random permutations

Q. How many permutations of N elements have k cycles

P21 = 1
P22 = 1

cumulated cost: 3
average: 1.5

Pb 1 = 2
Pb 2 = B
Pb b= 1

cumulated cost: 1 1
average: 1.8333

P41 = 6
P42 = 1 1
P43 = 6
P44 = 1

cumulated cost: 50

average: 2.0833

47

Cycles in random permutations

Class P, the class of all permutations

Size \p\, the length of p

Parameter cyc(p), the number of cycles in p

Example

EBCF

Construction

EBGF equation from symbolic method

Enumeration EGF
Cumulated cost EGF

Average # cycles in a random permutation

P = SET ( u CYC ( Z) )

„i„ 1

P(z. u) = e 1 — z = (1 — z)
P u(z, 1) = —In 1
— U

N\[z N \P u (z, 1) /TT\


N![z N ]P(z, 1)

N H

1.5

B 1.8BB
4 2.083

concentrated: c tn is 0(^log N)

48

EBGF of Stirling numbers of the 1st kind (cycle numbers)

N > 0 k >0

k
rN

N\

z N

u(u + 1)...(t; + N—1) — (horizontal EGF)

/ \ •

N >0

1 \/c k

Vl(ln—)

^ /d v 1 -z y

k >0

(1 z) u

(vertical EGF)

(EBGF)

A/

[l/^]l/(l/ + 1 )(l/ -h2 )(l/ + 3)—* 4

1
1

24

vertical OGF
coefficients

I I

3 1

II 6 1 <-

50 35 10

120 274 225 85 15

7 720 1764 1624 735 175

1 1 ^3

horizontal OGF
coefficients

21 1

49
Number of cycles of a given length in random permutations

Class P, the class of all permutations

Size \p\, the length of p

Parameter cyc r (p), # of cycles of length r in p

Example

EBCF

Construction

EBGF equation from symbolic method


Enumeration EGF

Cumulated cost EGF

P = SET ( CYC*r(Z) + u CYC=r(Z))

1 -,r ,,-,r

, . z uz

In --1-

P(z,u) =e 1 -z r r

PC 1 )

(u-iy/r

1 -z

1 -Z

N\[z N ]P u (z, 1) _/T\


N\[z N ]P(z, 1) \rj

Average # r-cycles in a random permutation


Set partitions

Q. How many ways to partition a set of size of N?

{ 1 } { 2 } { 3 } { 4 }
{ 1 } (2 3 4 }
{ 2 } {1 3 4 }
{ 3 } {1 2 4 }
{ 4 } {1 2 3 }

{ 1 }

{ 2 }

{ 3 }

{1

2 }

{ 3 }

{ 4 }

{ 1 }

{ 2 }

{ 1 }

{2

3 }

{1

3 }

{ 2 }

{ 4 }

{1

2 }

{ 2 }

{1
3 }

{1

4 }

{ 2 }

{ 3 }

52 =

= 2

{ 3 }

{1

2 }

{2

3 }

{ 1 }

{ 4 }

{ 1 }

{ 2 }

{ 3 }

{2

4 }

{ 1 }

{ 3 }

5 b

= 5

{3

4 }

{ 1 }

{ 2 }
{1 2 } {3 4 }
{1 3 } {2 4 }
{1 4 } {2 3 }

{ 1234 }
5 4 = 1 5

51

Set partitions

Q. How many ways to partition a set of size of N into k subsets ?

{ 1 } { 2 }

W {1 2}

S22 = 1

cumulated cost: 3
average: 1.5

{ 1 } { 2 } { 3 }
{ 1 } (2 3 }
{ 2 } {1 3 }
{ 3 } {1 2 }
{1 2 3 }

531 = 1

5 3 2 = 3

533 = 1

cumulated cost: 1 1
average: 2

{ 1 } { 2 } { 3 } { 4 }

{ 1 }

{2 3

4 }

{ 2 }
{1 3

4 }

{ 3 }

{1 2

4 }

{ 4 }

{1 2

3 }

{1 2 }

{ 3 }

{ 4 }

{1 3 }

{ 2 }

{ 4 }

{1 4 }

{ 2 }

{ 3 }

{2 3 }

{ 1 }

{ 4 }

{2 4 }

{ 1 }

{ 3 }

{3 4 }

{ 1 }

{ 2 }

{1 2 } {3

4 }

{1 3 } {2

4 }
{1 4 } {2

3 }

{ 1234 }

S 4 i = 1
S 4 2= 7

543 = 6

544 = 1

cumulated cost: 37

average: 2.466

52

Number of subsets in set partitions

Class

S, the class of all set partitions

Example

{1} {2 5 6} {3 7 8} {4}

Size

size of the set

5(z, u) = ^j|u su6sets(s)

5<ES 5 '

Parameter

number of subsets in the partition

EBGF

Construction
EBGF equation from symbolic method

Enumeration EGF

Cumulated cost EGF

Average # subsets in a random set partition

5 = SET ( u SET> 0 (Z))

5(z, u ) — e a ( e — 1)

5(z,1) = e eZ - 1

5„(z, 1) = (e z - 1)e( e

N'.[ zN ]S u (z, 1) _

N\[z N ]S(z, 1)

1 )

need complex asymptotics


(stay tuned)

EBGF of Stirling numbers of the 2nd kind (partition numbers)

N> 0 k>0

N) z
k ) ~N\ U

= J2 Bn (°)

N> 0

= 5]( ez

k>0

(horizontal EGF)
"Bell polynomials"
(vertical EGF)

= e U ^ Z 1 ) (EBGF)

horizontal EGF
coefficients

/C^

6 7

vertical EGF
coefficients

1
4

<-

[(/]5 4 (t/)

15

25

10

31

90

65

15

63

301

350

140

21 1

N![z w ]l(e^-1) 3
54

Mappings

Def. A mapping is a function from the set of integers from 1 to N onto itself.

Example

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32 33 34 35 36 37
9 12 29 33 5 20 30 37 26 20 13 8 2 33 29 2 35 37 33 9 35 21 18 2 25 1 20 33 23 18
29 5 5 9 11 5 11

55

Mapping EGFs (see lecture on EGFs)

Combinatorial class C, the class of Cayley trees < -labelled, rooted, unordered

Construction

C = Z * (557(C)) «— "a tree is a root connected to a set of trees"

EGF equation

C(z) = ze c<yZ )

Combinatorial class Y, the class of mapping components

Construction

y — CYC(C) <— "a mapping component is a cycle of trees"

EGF equation

Y(Z) - ln 1 - C(z)

Combinatorial class C, the class of Cayley trees


Construction

M — SET(CYC(C)) <— "a mapping is a set of components"

EGF equation

MW-expOn z) )_ z)

56

Mapping parameters

are available via EBGFs based on the same constructions


Ex 1. Number of components

Construction M = SET(uCYC(C))

1 1

EGF equation M{z) = exp (u In - _ ) =

Ex 2. Number of trees (nodes on cycles)

Construction M = SET(CYC(uC))

1 1

EGF equation M(z) = exp(ln -—= - ——

v 1 - uC{z)' 1 — uC(z)

Q. Moments? Coefficients? Other parameters?

A. Stay tuned for general theorems from complex aysmptotics.

57
"We shall now stop supplying examples that could be multiplied ad libitum, since
such
calculations greatly simplify when interpreted in the light of asymptotic analysis"

— Philippe Flajolet, 2007

ANALYTIC COMBINATORICS

PART TWO

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

3. Combinatorial parameters and MGFs

^Moment calculations

f^GBGF examples

• Labelled classes

CAMBRIDGE

http://ac.cs.princeton.edu

II.3d.MGFs.EBGFs

ANALYTIC COMBINATORICS

PART TWO

o^pmbinalorial parafn^ters and MGFs

• Moment calculations
s r©BGF examples
• Labelled classes

• Exercises

http://ac.cs.princeton.edu

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

CAMBRIDGE

II.3e.MGFs.Exercises

Note 111.17

Leaves in Cayley trees

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

> III-17- Leaves and node-degree profile in Cayley trees. For Cayley trees, the
bivariate EGF
with u marking the number of leaves is the solution to

T(z,u) = uz + z(e T{z ' u) - 1).

(By Lagrange inversion, the distribution is expressible in terms of Stirling


partition numbers.)
The mean number of leaves in a random Cayley tree is asymptotic to ne ~ 1 . More
generally, the
mean number of nodes of outdegree k in a random Cayley tree of size n is asymptotic
to

Degrees are thus approximately described by a Poisson law of rate 1. <1

61
Note 111.21

After Bhaskara Acharya

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

> 111 . 21 . After Bhaskara Acharya ( circa 1150 ad). Consider all the numbers
formed in decimal

with digit 1 used once, with digit 2 used twice.with digit 9 used nine times. Such
numbers

all have 45 digits. Compute their sum S and discover, much to your amazement that S
equals

458755596000061532190847692863 999999999999999 54124440399993846780915230713600000.

This number has a long run of nines (and further nines are hidden!). Is there a
simple explana¬
tion? This exercise is inspired by the Indian mathematician Bhaskara Acharya who
discovered
multinomial coefficients near 1 150ad. <1

45875559600006153219084769286399999999999999954124440399993846780915230713600000

62

Assignments

1. Read pages 151-219 in text.

2. Write up solutions to Notes III. 1 7 and 111.21.

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick
3. Programming exercise.

Program III. 1 . Write a program that generates 1000 random


permutations of size N for N = 1 0 3 , 1 0 4 , ... (going as far as you
can) and plots the distribution of the number of cycles, validating
that the mean is concentrated at Hn.

63

ANALYTIC COMBINATORICS

PART TWO

Analytic

Combinatorics

Philippe Flajolet and


Robert Sedgewick

3. Combinatorial Parameters

and MGFs

http://ac.cs.princeton.edu

Das könnte Ihnen auch gefallen