top | item 5197366

Random walk illustrated with D3

52 points| mixedbit | 13 years ago |mixedbit.org | reply

13 comments

order
[+] paulgb|13 years ago|reply
The code for this is neat and impressively short, anyone looking to see the power of D3 should check it out: https://gist.github.com/wrr/4750218

My only suggestion is that .data([color_idx]) would be more idiomatic (I think) if it were .datum(color_idx)

[+] mixedbit|13 years ago|reply
Thanks! It is now changed to datum().
[+] nevinera|13 years ago|reply
"A moral of this is that any lucky series will always eventually be reversed and an expected outcome of a random walk is always 0. Or in other words - don’t play roulette ;)"

The apriori expected outcome of a random walk is zero. The expected outcome of a random walk from a given position is the position itself. So no, 'any lucky series' will not 'always eventually be reversed'. I'm afraid that's not how probability works.

But you still shouldn't play roulette.

[+] mixedbit|13 years ago|reply
The way I understand this, is that for a random walk of infinite length, your expected outcome is always 0. It doesn't matter that you started very lucky by winning 10 games in a row, because if you play an infinite number of times, you will balance this by loosing 10 games in a row (you'll do it an infinite number of times).

In real life people usually don't play an infinite number of times, but the more you play, the better the theory approximates your final outcome. After very large number of games, you will very likely encounter a bad luck series.

This is a bit counter intuitive, because according to the theory, there is a difference between a person that enters a fair game with 10$ and a person that enters with 1$ and wins 9$ in the first 9 games. The first person is expected to finish with 10$, the second with 1$, even though both have the same amount of money at some point. But laws that involve infinity are often counter intuitive.

[+] mikeash|13 years ago|reply
Interesting fact about the interesting facts at the bottom: each point is reached an infinite number of times only when a random walk is performed in one or two-dimensional space. For dimensions >=3, an infinite walk visits each point a finite number of times, which means that, while the random walker may return to the starting point one or more times after starting, it will eventually wander off forever. This has been described as, "A drunk man will find his way home, but a drunk bird may get lost forever."
[+] mturmon|13 years ago|reply
I had forgotten that one. You inspired me to visit Wikipedia where I learned that the probability of a 3D random walk returning to the origin (given an unbounded number of steps) is about .34 (in 2D, as you note, this probability is 1). The probability of eventual return goes down as dimensionality increases. As you say, get lost forever.
[+] misleading_name|13 years ago|reply
Doesn't work on my Windows Firefox... got it working on Chrome though.