Plot Wiener Process and its running maximum

I want to plot a Wiener process $B=(B_{t})_{t≥0}$ and its running maximum $S_{1}=\max_{0\leq t\leq1}B_{t}$ on Mathematica. Can anybody help? I only know how to generate a Wiener process using RandomFunction, but I have no idea how to plot its running maximum.

thank you! any help is appreciated

edit: Thank you for the answers! How do I plot the reflected process $S-B$ ? Is there a command that given the two graphs, outputs their difference?

• Well, okay, show us what you have made so far :) – Sektor Apr 1 '14 at 14:46
• You could try using FoldList[Max, .... over the list of values generated with RandomFunction – Rojo Apr 1 '14 at 15:05
• ListLinePlot[RandomFunction[WienerProcess[], {0, 1, 0.01}], AxesOrigin -> {0, 0}] I get the Wiener Process with this. – user139493 Apr 1 '14 at 15:20

It is always nice to have alternative solutions. The following sets up a function which holds its value until a larger value is presented to it.

rMax[ts_] :=
Block[{max = -\[Infinity], rmax},
rmax[x_ /; x <= max]:= max;
rmax[x_]:= (max = x; x);
rmax /@ ts
]

Lets generate some data and extract out the states.

SeedRandom;
s = RandomFunction[WienerProcess[], {0, 1, .001}]["PathStates"];

for convenience, since the data runs from zero to one, we can set the DataRange rather than constructing ordered pairs.

ListLinePlot[{s, rMax[s]}, DataRange -> {0, 1}] Hopefully there will be some helper functions for working with TemporalData in future versions of M that will make all of this easier!

• Thank you! can you see if you can help with the edit to my question? I kind of answered myself by doing: ListLinePlot[{s, rMax[s], rMax[s] - s}, DataRange -> {0, 1}]. Is that alright? – user139493 Apr 1 '14 at 21:04
• Yes, that is correct. – Andy Ross Apr 2 '14 at 3:27
Module[{s=4},
Show[
ListLinePlot[{SeedRandom[s];RandomFunction[WienerProcess[],{0,1,0.01}]},AxesOrigin->{0,0}],
ListLinePlot[{SeedRandom[s];Apply[Transpose[{#1,FoldList[Max,First[#2],Rest[#2]]}]&,
Transpose[First[Normal[RandomFunction[WienerProcess[],{0,1,0.01}]]]]]},AxesOrigin->{0,0}]]]

Some, ahem, fannying around with First[Normal... to dig out the actual time series pairs is required.

• Thank you very much, the result is exactly what I wanted. I'm a very beginner with mathematica but needed to implement my school project with graphs. The code you wrote looks very complicated, I thought it would have been easier ^^, anyway thank you! it looks like I will have to spend a lot of time on this.. – user139493 Apr 1 '14 at 15:43