February 24th, 2005, 9:50 am
In Mathematica,We define a Wiener process:<<Statistics`ContinuousDistributions`rnorm:=Random[NormalDistribution[0,1]];rwiener[freq_:100]:=NestList[#+{1/freq,rnorm/Sqrt[freq]}&,{0.,0.},freq];We define a Brownian bridge:rbridge[freq_:100]:=Module[{t,w},{t,w}=Transpose[rwiener[freq]];Transpose[{t, t w[[freq]]-w}]]Simulation of X:simCumDist[x_,runs_:100,freq_:100]:= Module[{eachRun:=Module[{t,b}, {t,b}=Transpose[rbridge[freq]]; If[Max<x,1.,0.]]}, Sum[eachRun,{runs}]/runs];TableForm[{#,simCumDist[#,1000,1000]}&/@{0.25,0.75,1.5}]0.25 0.1360.75 0.6851.5 0.989Verification using the analytical approximation:P[x_]:=1-Exp[-2 x^2];TableForm[{#,P[#]}&/@{0.25,0.75,1.5}]0.25 0.117503097415404540.75 0.67534753264165031.5 0.9888910034617577If I remember correctly the GNU R has a nice implementation. Google it.