Properties
Similar Topics
Statistics
Comments
5
Participants
3
Subscribers
3
Votes
1
Views
651
Share
How can I generate a random walk?
Answered
How can I define random walk in Geogebra? Say we choose 1 or 1 with equal probability N times, and then we want to define a rescaled function f(x) out of it.
In other words, let N be a fixed integer (given by a slider). I would like to define the following function of x, where x is a real parameter on the interval [0,1]:
Jumps = Sequence(RandomElement({1, 1}), i, 1, N)
f(x) = Sum(Jumps, ceil(N*x))
This code does not work. I have not found a way to do this.
 GeoGebra
 Help
 Partners

Contact us
 Feedback & Questions
 This email address is being protected from spambots. You need JavaScript enabled to view it.
 +43 677 6137 2693
© 2021 International GeoGebra Institute
If you combine IterationList() with this then I think that will be a bit faster (you also need an UpdateConstruction() in the slider's On Update script if you want it to be dynamic)
Thank you. Very helpful. It's not 100% what I would like, as there are two problems:
1. I would prefer the function to be a stepwise function, not triangular (that's why I used "ceil" in my formula).
2. Your code to compute l1 will be inefficient for large N. How can we compute l1 by running through the Jumps list only once?
Here your points 1 and 2 will be met.
The performance is low (I suspect, on the basis of the requirement in point 1.). Possibly a BarChart() diagramm or a Polyline() is more performant.
Ok, thank you to Michael and rami. IterationList!
If you combine IterationList() with this then I think that will be a bit faster (you also need an UpdateConstruction() in the slider's On Update script if you want it to be dynamic)
Comments have been locked on this page!