Article 59SE7 Random Fibonacci numbers

Random Fibonacci numbers

by
John
from John D. Cook on (#59SE7)

The Fibonacci numbers are defined by F1 = F2 = 1, and for n > 2,

Fn = Fn-1 + Fn-2.

A random Fibonacci sequence f is defined similarly, except the addition above is replaced with a subtraction with probability 1/2. That is, f1 = f2 = 1, and for n > 2,

fn = fn-1 + b fn-2

where b is +1 or -1, each with equal probability.

Here's a graph a three random Fibonacci sequences.

rand_fib1.png

Here's the Python code that was used to produce the sequences above.

 import numpy as np def rand_fib(length): f = np.ones(length) for i in range(2, length): b = np.random.choice((-1,1)) f[i] = f[i-1] + b*f[i-2] return f

It's easy to see that the nth random Fibonacci number can be as large as the nth ordinary Fibonacci number if all the signs happen to be positive. But the numbers are typically much smaller.

The nth (ordinary) Fibonacci number asymptotically approaches n is the golden ratio, = (1 + 5)/2 = 1.618...

Another way to say this is that

fibasymp.svg

The nth random Fibonacci number does not have an asymptotic value-it wanders randomly between positive and negative values-but with probability 1, the absolute values satisfy

randfibasymp.svg

This was proved in 1960 [1].

Here's a little Python code to show that we get results consistent with this result using simulation.

 N = 500 x = [abs(rand_fib(N)[-1])**(1/N) for _ in range(10)] print(f"{np.mean(x)}  {np.std(x)}")

This produced

1.1323 0.0192

which includes the theoretical value 1.1320.

Update: The next post looks at whether every integer appear in a random Fibonacci sequence. Empirical evidence suggests the answer is yes.

Related posts

[1] Furstenberg and Kesten. Products of random matrices. Ann. Math. Stat. 31, 457-469.

The post Random Fibonacci numbers first appeared on John D. Cook.

YIcLtt1S5C0
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/TheEndeavour?format=xml
Feed Title John D. Cook
Feed Link https://www.johndcook.com/blog
Reply 0 comments