Attachment 'random_walk.rst'

Download

Random walk on the discrete line

Average jump

The thirst street is made of a juxtaposition of bars labelled 0, 1, 2, …, starting from downtown (bar number 0). A bunch of drunkards is drinking in bar 0. At midnight, all of them are kicked out of the bar. Every minute, each drunkard either stays at its position with probability 1 ⁄ 2, or jumps in the next bar with probability 1 ⁄ 2, they are so drunk that the jumps are independent, and the drunkards do not interact with each other. We want to understand how the drunkards get distributed when n is large.

Write a function drunkard_jumps(n) which samples a list of n jumps (with values 0 or 1).

Hint: you can have a look at the randint function.

Write a function drunkard_positions(n) which returns a list of n consecutive positions of such a drunkard, starting at position 0.

Write a function plot_drunkard_positions(n) which plots the sequence of positions as a function {0, …, n − 1} → ℕ.

Hint: you can have a look at the enumerate, point2d and line2d functions. Starting from an empty Graphics() object and adding of several graphics objects to it results in the superposition of those graphics.

Extend this to a function plot_drunkard_positions(n,d) which samples the sequences of d drunkards on the same graphic and observe the result.

Hint: You can have a look at the rainbow function to get a sequence of different colors, and use the color option in the graphics objects.

Write a function drunkard_average_speeds(n) which returns a list of n consecutive average speeds, that is, for each i <= n-1, the average number of bars visited from 0 to i per minute.

Write a function plot_drunkard_average_speeds(n,d) that plots the the consecutive average speeds of d drunkards up to n minutes.

Hint: if you think that this function is very close to plot_drunkard_positions(n,d), you can try to refactor your code by writing a single plot_samples(function,n,d), to be applied to the drunkard_positions and drunkard_average_speeds functions.

Formulate a conjecture on the long-term behaviour of the average speed of the drunkards.

Scattering

To avoid accidents caused by dangerous cars, an enlightener lifeguard is following the group of drunkards at constant speed 1 ⁄ 2 bar per minute with a light.

Write a function plot_enlightener_view(n,d) that plots the trajectories of d drunkards from the point of view of the enlightener lifeguard.

In order to save energy, the enlightener lifeguard wants to know how far should her light illuminate in order to enlighten most drunkards. Of course, after n minutes, a distance of n ⁄ 2 bars is enough to ensure that all drunkards are illuminated, whatever the probabilities. But she wants to save more energy, while still illuminating most drunkards.

Write a function guess_scattering(n,d) to help you guess the best α in [0, 1] such that a light illuminating nα after n minutes illuminates most drunkards.

Hint: the logarithm helps to discover polynomial and exponential rates.

Write a function plot_scattered_enlightener_view(n,d) that adds to the enlightener lifeguard's view, some constant (positive and negative) multiples of nα.

Formulate a conjecture on the second order long-term behaviour of the trajectories of the drunkards.

Distribution

After n minutes, the drunkards fall asleep, and the lamp illuminates them. The enlightener lifeguard takes a picture of the "heap" of sleeping drunkards. The zoom is such that the picture boundaries corresponds to the enlightened part of the street.

Write a function asleep_drunkard_distribution(n,d) that plots the distribution of d asleep drunkards on the picture after n steps.

Formulate a conjecture on the limit shape of the heap of asleep drunkards (d might depend on n, do not forget the zoom).

Write an animation that shows the convergence to some limit curve when n tends to infinity.

Universality

The day after, the drunkards got sick of alcohol and decide to take some ecstasy. Now, at each second, they are jumping by a step si with probability pi, where:

  • si ∈ ℝ (0 ≤ i < k)
  • pi ∈ [0, 1] (0 ≤ i < k)
  • k − 1i = 0pi = 1

Try to extend and illustrate the previous laws to this setting.

Hint: you can have a look at the random function.

Conclusion

Drunkards let us discover the folloging laws of probabilities:


Authors:
  • Thierry Monteil
  • Vincent Delecroix
License:

CC BY-SA 3.0

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2018-08-12 22:01:42, 8.3 KB) [[attachment:CollatzConjecture.ipynb]]
  • [get | view] (2018-08-12 22:01:45, 100.9 KB) [[attachment:CollatzConjecture.pdf]]
  • [get | view] (2018-08-12 22:01:49, 4.8 KB) [[attachment:CollatzConjecture.rst]]
  • [get | view] (2018-08-12 22:01:53, 12.3 KB) [[attachment:Dictionaries-GraphTheory.ipynb]]
  • [get | view] (2018-08-12 22:01:56, 202.6 KB) [[attachment:Dictionaries-GraphTheory_Solutions.pdf]]
  • [get | view] (2018-08-12 22:02:00, 9.1 KB) [[attachment:Dictionaries-GraphTheory_Solutions.rst]]
  • [get | view] (2018-08-15 12:32:58, 16.0 KB) [[attachment:Fields-2018-flatsurf_and_surface_dynamics_demo.ipynb]]
  • [get | view] (2018-08-11 19:25:37, 15.0 KB) [[attachment:S_2_1.svg]]
  • [get | view] (2018-08-12 22:02:10, 13.4 KB) [[attachment:Strings-BWT.ipynb]]
  • [get | view] (2018-08-12 22:02:14, 72.4 KB) [[attachment:Strings-BWT.pdf]]
  • [get | view] (2018-08-12 22:02:17, 7.0 KB) [[attachment:Strings-BWT.rst]]
  • [get | view] (2018-08-11 19:28:42, 16.7 KB) [[attachment:chap1-first_steps.ipynb]]
  • [get | view] (2018-08-11 19:28:46, 103.1 KB) [[attachment:chap1-first_steps.pdf]]
  • [get | view] (2018-08-11 19:28:53, 7.8 KB) [[attachment:chap1-first_steps.rst]]
  • [get | view] (2018-08-11 19:29:05, 24.6 KB) [[attachment:chap1-first_steps_solutions.ipynb]]
  • [get | view] (2018-08-11 19:29:09, 108.7 KB) [[attachment:chap1-first_steps_solutions.pdf]]
  • [get | view] (2018-08-11 19:29:12, 12.0 KB) [[attachment:chap1-first_steps_solutions.rst]]
  • [get | view] (2018-08-11 19:29:17, 30.8 KB) [[attachment:chap2-list_and_for.ipynb]]
  • [get | view] (2018-08-11 19:29:23, 110.0 KB) [[attachment:chap2-list_and_for.pdf]]
  • [get | view] (2018-08-11 19:29:26, 17.6 KB) [[attachment:chap2-list_and_for.rst]]
  • [get | view] (2018-08-11 19:29:32, 42.0 KB) [[attachment:chap2-list_and_for_Solutions.ipynb]]
  • [get | view] (2018-08-11 19:29:35, 116.1 KB) [[attachment:chap2-list_and_for_Solutions.pdf]]
  • [get | view] (2018-08-11 19:29:38, 25.6 KB) [[attachment:chap2-list_and_for_Solutions.rst]]
  • [get | view] (2018-08-11 19:29:51, 21.1 KB) [[attachment:chap3-if-solutions.ipynb]]
  • [get | view] (2018-08-11 19:29:58, 95.4 KB) [[attachment:chap3-if-solutions.pdf]]
  • [get | view] (2018-08-11 19:29:55, 9.0 KB) [[attachment:chap3-if-solutions.rst]]
  • [get | view] (2018-08-11 19:29:41, 11.8 KB) [[attachment:chap3-if.ipynb]]
  • [get | view] (2018-08-11 19:29:45, 91.6 KB) [[attachment:chap3-if.pdf]]
  • [get | view] (2018-08-11 19:29:48, 5.7 KB) [[attachment:chap3-if.rst]]
  • [get | view] (2018-08-11 19:30:02, 4.4 KB) [[attachment:chap4-functions.ipynb]]
  • [get | view] (2018-08-11 19:30:06, 83.1 KB) [[attachment:chap4-functions.pdf]]
  • [get | view] (2018-08-11 19:30:09, 2.3 KB) [[attachment:chap4-functions.rst]]
  • [get | view] (2018-08-11 19:30:20, 3.2 KB) [[attachment:chap5-while.ipynb]]
  • [get | view] (2018-08-11 19:30:14, 62.1 KB) [[attachment:chap5-while.pdf]]
  • [get | view] (2018-08-11 19:30:39, 1.5 KB) [[attachment:chap5-while.rst]]
  • [get | view] (2018-08-11 19:30:47, 4.0 KB) [[attachment:chap6-advanced_exercises.ipynb]]
  • [get | view] (2018-08-11 19:30:53, 69.7 KB) [[attachment:chap6-advanced_exercises.pdf]]
  • [get | view] (2018-08-11 19:31:00, 2.0 KB) [[attachment:chap6-advanced_exercises.rst]]
  • [get | view] (2018-08-12 22:02:04, 90.9 KB) [[attachment:euler.png]]
  • [get | view] (2018-08-13 21:52:57, 1.1 KB) [[attachment:flipper_nf_conversion.py]]
  • [get | view] (2018-08-15 12:18:55, 55.4 KB) [[attachment:flipper_tutorial.pdf]]
  • [get | view] (2018-08-12 21:56:57, 16.1 KB) [[attachment:floating_point_and_stability.ipynb]]
  • [get | view] (2018-08-12 21:57:01, 78.0 KB) [[attachment:floating_point_and_stability.pdf]]
  • [get | view] (2018-08-12 21:57:04, 6.6 KB) [[attachment:floating_point_and_stability.rst]]
  • [get | view] (2018-08-12 22:02:07, 17.6 KB) [[attachment:graph0.png]]
  • [get | view] (2018-08-11 23:44:38, 23.2 KB) [[attachment:intro.en.ipynb]]
  • [get | view] (2018-08-11 23:44:45, 117.5 KB) [[attachment:intro.en.pdf]]
  • [get | view] (2018-08-11 23:44:53, 12.5 KB) [[attachment:intro.en.rst]]
  • [get | view] (2018-08-12 23:25:35, 62.3 KB) [[attachment:logistic_orbit_interact.png]]
  • [get | view] (2018-08-11 19:48:34, 9.6 KB) [[attachment:random_walk.ipynb]]
  • [get | view] (2018-08-11 19:48:38, 87.9 KB) [[attachment:random_walk.pdf]]
  • [get | view] (2018-08-11 19:48:44, 5.7 KB) [[attachment:random_walk.rst]]
  • [get | view] (2018-08-15 19:25:46, 67.3 KB) [[attachment:real_and_complex_numbers.ipynb]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.