I'm trying to plot the first 100 values of this random walk function using F#/Xamarin. Whenever I call the function, my application freezes. I tried to get the count on this.RW, but that also freezes the application. Help appreciated!
module SimulatingAndAnalyzingAssetPrices =
type RandomWalk(price : float) =
let sample = Normal(0.0, 1.0).Sample()
// Generate random walk from 'value' recursively
let rec randomWalk price =
seq {
yield price
yield! randomWalk (price + sample)
}
let rw = randomWalk 10.0
member this.RW = rw
Note: This is from tryfsharp.org's finance section. My intent is to port it to iOS using Xamarin.
Edit: Tried using the following code, but still getting an infinite sequence:
let rw = randomWalk 10.0
let rwTake = Seq.take 100 rw
member this.RwTake = rwTake
Edit 2: Also tried
let rw = randomWalk 10.0 |> Seq.take 100
member this.RwTake = rw