on buffon machines & numbers - inriaalgo.inria.fr/flajolet/publications/slides/bkk09.pdf · •...

36
On Buffon Machines & Numbers Philippe FLAJOLET , INRIA-Rocquencourt, France With Maryse PELLETIER & Michèle SORIA , LIP6, Paris ~~~ Bangkok, October 2009 ~~~ Arxiv & http://algo.inria.fr/flajolet/ 1 Wednesday, October 21, 2009

Upload: others

Post on 02-Jun-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

On Buffon Machines & NumbersPhilippe FLAJOLET,

INRIA-Rocquencourt, France

With Maryse PELLETIER & Michèle SORIA, LIP6, Paris~~~ Bangkok, October 2009 ~~~

Arxiv & http://algo.inria.fr/flajolet/

1Wednesday, October 21, 2009

Page 2: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

Themes:Computability theory: the power of probabilistic devices

Simulation: how to be discrete & perfect?

Further connexions: special functions, analytic combinatorics, discrete processes, analysis of algorithms [ASIAN Schools & Confs]....

2Wednesday, October 21, 2009

Page 3: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

1733: Countess Buffon drops her knitting kit on the floor.

Count Buffon picks it up and notices that about 63% of the needles intersect a line on the floor.

Oh-Oh! 0.6366 is almost 2/pi (!)...

3Wednesday, October 21, 2009

Page 4: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• A large body of literature on real-number simulations, starting with von Neumann, Ulam, Metropolis,...

• Luc Devroye’s monumental synthesis, which is available on the web: @ http://cg.scs.carleton.ca/~luc/

4Wednesday, October 21, 2009

Page 5: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

What to do if you travel and don’t want to carry floor planks and knitting needles?

Assume you have a coin!

Insist on PERFECT simulations!

5Wednesday, October 21, 2009

Page 6: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Assume you have a coin.+ Insist on perfect simulations.

• The problem is trivial!!!!!! Everything that is computable can be simulated.

• Numbers: +

+

1/π

0 17/22 1/36Wednesday, October 21, 2009

Page 7: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Assume you have a coin.+ Insist on perfect simulations.

• The problem is trivial!!!!!! Everything that is computable can be simulated.

• Functions: +

+

[Nacu & Peres 2005]

7Wednesday, October 21, 2009

Page 8: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Needs large computational power:requires arbitrary-precision routines; program size is HUGE & computational complexity is hard to assess precisely.

• Does not qualify as “simple process”; typically, not human-implementable.

8Wednesday, October 21, 2009

Page 9: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

1. The framework

9Wednesday, October 21, 2009

Page 10: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

{0,1}

• A Buffon machine is a machine or program that has access to a pure source of perfect coin flips and outputs {0,1}-values, or, in some cases, integers.

• It may not involve multi-precision arithmetics, only basic probabilistic processes, be simple(!) and efficient(!).

• Buffon machines have no permanent memory => they can only produce i.i.d random variables; typically, Bernoulli.

{0,1}

ΓB(p)

10Wednesday, October 21, 2009

Page 11: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Can you do such numbers as

with only basic coin flips and no arithmetics.

• Simulation: expected # flips is finite.Strong simulation: + has exponential tails.

???

{0,1}

11Wednesday, October 21, 2009

Page 12: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• A Buffon machine may also call black boxes sampling from Bernoulli distributions of unknown parameters.

• A machine computes φ(p), if given a machine ΓB(p) for Bern(p) [p unknown!] as subroutine, its output is a Bern(φ(p)).

• In this way Buffon machines can be composed from simpler ones...

{0,1}

12Wednesday, October 21, 2009

Page 13: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• All rational numbers and functions in (0,1)

• All positive algebraic functions (context-free)

• Closure under half-sum, product, composition

• Exponentials, logarithms; polylogs; trig functions

• Closure under integration; inverse trigs

• Hypergeometrics of “binomial type”

• + Poisson and logarithmic-series generators

• Meta-thorem: You can do, constructively, simply and efficiently:

13Wednesday, October 21, 2009

Page 14: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• We shall see nine ways to get π, some with 5 coin flips on average, with typically about a dozen lines of code...

14Wednesday, October 21, 2009

Page 15: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Builds on ideas of von Neumann, Knuth-Yao

• Encapsulates constructions by Wästlund, Nacu, Peres, Mossel

• Develops new constructions: VN-generator, integration; Poisson & logarithmic distributions.

15Wednesday, October 21, 2009

Page 16: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

2. Basic construction rules

16Wednesday, October 21, 2009

Page 17: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Decision trees and loopless programsDo Bernoulli of param. 3/8,5/8; dyadic rationals“Compute” Boolean combinations

AND

p

q

p.q

p.q

1-p

(p+q)/2

p2

17Wednesday, October 21, 2009

Page 18: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Finite graphs and Markov chains

• Can do all rational p:To do a ΓB(3/7), flip three times; in 3 cases, return(1); in 4 cases return(0); otherwise repeat.

• From a ΓB(p); repeatedly try till 1 is observed. If number of trials is even, then return(1).Computes 1/(1+p) = (1-p)[1+p2+p4+ ...]

do a geometric ΓG(p) from a Bernoulli ΓB(p)

18Wednesday, October 21, 2009

Page 19: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Mossel, Nacu, Peres, Wästlund:

• .... but it requires arbitrary-precision routines.

19Wednesday, October 21, 2009

Page 20: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

3. The von Neumann schema

20Wednesday, October 21, 2009

Page 21: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

geometric

• Choose a class of permutations with Pn the number of those of size n.

• Draw N∈Geo(λ) uniform Random Variables over [0,1].

• Succeed if the order type is good = in Pn.

21Wednesday, October 21, 2009

Page 22: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Choose a class of permutations with Pn the number of those of size n. Draw N=Geom(lambda).

• Probability of success with N=n is

• Thus, get Poisson and logarithmic distributions

n

22Wednesday, October 21, 2009

Page 23: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Using a digital tree (aka trie), we only need a single string register to recognize perm classes for Poisson and logarithmic distribs!

• Poisson = sorted perms: U1< U2< U3

• Logarithmic = max-first perms: U1 > U2 , U3

Uk U1

cf Leader election: Prodinger; Fill, Mahmoud, Szpankowski, Janson,...☝ ☝

23Wednesday, October 21, 2009

Page 24: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• For VN schema, path-length of tries determines # coin flips.

PGF:

24Wednesday, October 21, 2009

Page 25: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Poisson: Declare success (1) if N=0; failure o.w. Get exp(-λ), etc.

• Check P: Do only one run; return(1) if success. E.g, for Poisson, gives (1-λ)exp(λ)

• Use alternating (zigzag) perms & get trigs!

25Wednesday, October 21, 2009

Page 26: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Polylogarithms, Bessel,...: do r experiments

Get log(2), then π2/24, in less than 10 flips on average

26Wednesday, October 21, 2009

Page 27: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

4. Square roots, algebraic & hypergeometric functions

27Wednesday, October 21, 2009

Page 28: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Generate N∈Geo(λ) and succeed if we get a balanced score from 2N flips.

• The probability of success:

28Wednesday, October 21, 2009

Page 29: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Get hypergeometrics of binomial type.

Ramanujan:

<11 coin flips on average

29Wednesday, October 21, 2009

Page 30: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

5. A Buffon integrator

30Wednesday, October 21, 2009

Page 31: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• In a construction of a ΓB(φ(λ)) from a ΓB(λ), we substitute a ΓB(Uλ), with U uniform. Get an integrator:

• We can do a product ΓB(Uλ)=ΓB(U).ΓB(λ) by an AND (∧) as well as by emulating a uniform U with a “bag”:

31Wednesday, October 21, 2009

Page 32: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Chain: p ➜p2 ➜1/(1+p2) ➜ arctan(x)∫

32Wednesday, October 21, 2009

Page 33: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Madhava-Gregory-Leibniz: arctan(1)=π/4

• Machin machine: arctan(1/2)+arctan(1/3)=π/4.

Distribution of costs (plain & log.)

6.5 flips on average

33Wednesday, October 21, 2009

Page 34: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

6. Experiments

34Wednesday, October 21, 2009

Page 35: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

MAPLE: an interpreter

~ 60 lines

35Wednesday, October 21, 2009

Page 36: On Buffon Machines & Numbers - Inriaalgo.inria.fr/flajolet/Publications/Slides/bkk09.pdf · • A Buffon machine is a machine or program that has access to a pure source of perfect

• Implements all earlier constructions: it works!

• Results for π-related constants:

Method; constant; mean # flips

36Wednesday, October 21, 2009