The Survival Probability for a walker starting at the origin is defined as the probability that the walker stays positive through n steps. Thanks to the Sparre-Andersen Theorem I know this PDF is given by
Plot[Binomial[2 n, n]*2^(-2 n), {n, 0, 100}]
However, I want to validate this empirically.
My attempt to validate this for n=100
:
FoldList[
If[#2 < 0, 0, #1 + #2] &,
Prepend[Accumulate[RandomVariate[NormalDistribution[0, 1], 100]], 0]]
I wantFoldList
to stop if #2 < 0
evaluates to True
, not just substitute in 0.
n=100
isBinomial[2 (100), (100)]*2^(-2 (100))
? So repeatedly run, and count the times you survive through 100 steps? If so, are you trying to "While" out of the FoldList to save CPU cycles? Not clear to me... $\endgroup$