Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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.

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}]

enter image description here

Hopefully there will be some helper functions for working with TemporalData in future versions of M that will make all of this easier!

share|improve this answer
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

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

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.