-
-
Save paavohuhtala/04cc6685192525248df851e571e47f91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Collections.Generic | |
let samples = 100000 | |
let rand = Random() | |
let lenTo1 () = | |
Seq.unfold (fun sum -> if sum > 1.0 then None else Some ((), sum + rand.NextDouble ())) 0.0 | |
|> Seq.length | |
Seq.initInfinite (fun _ -> lenTo1 ()) | |
|> Seq.take samples | |
|> Seq.map float | |
|> Seq.average | |
|> printfn "%f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment