Results 1 to 4 of 4

Math Help - Brownian Motion in MATLAB

  1. #1
    Super Member Anonymous1's Avatar
    Joined
    Nov 2009
    From
    Big Red, NY
    Posts
    517
    Thanks
    1

    Brownian Motion in MATLAB

    Hey,

    I'm supposed to use a box-muller transform to generate two independent realizations of Brownian motions.

    I have not had much exposure to Brownian Motion. So, I've got the Box-Muller Transform done and I'm drawing a blank on what to do next in order to "generate two independent realizations of Brownian motions."

    Any help is greatly appreciated.

    Thanks.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Moo
    Moo is offline
    A Cute Angle Moo's Avatar
    Joined
    Mar 2008
    From
    P(I'm here)=1/3, P(I'm there)=t+1/3
    Posts
    5,618
    Thanks
    6
    Hello,

    Here is what we did in Scilab (should be similar to Matlab) for a Brownian motion :

    Code:
    function X=Brownian(N,T)
      X=zeros(N+1,1);
      X(1)=0;
      for k=2:(N+1)
        X(k)=X(k-1)+(T/sqrt(N))*rand(1,1,'norm');
      end
    endfunction
    
    X=Brownian(200,1);
    clf();
    plot(X)
    Instead of rand(1,1,'norm'), include your Box-Muller thing.
    Adapt it to get 2 Brownian motion (should not be difficult, since the BM transform actually gives 2 normal random variables ^^)
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor

    Joined
    Aug 2008
    From
    Paris, France
    Posts
    1,174
    Quote Originally Posted by Moo View Post
    Code:
    function X=Brownian(N,T)
      X=zeros(N+1,1);
      X(1)=0;
      for k=2:(N+1)
        X(k)=X(k-1)+(T/sqrt(N))*rand(1,1,'norm');
      end
    endfunction
    
    X=Brownian(200,1);
    clf();
    plot(X)
    Just a few tips...
    I guess T is the final time; so it should be "sqrt(T)" in the formula. And for this scaling to have some meaning, time should be scaled as well (on the plot).
    As a piece of advice: you shouldn't perform the multiplication by sqrt(T/N) at each step: scilab is going to compute N times this square root. And scilab is very matrix oriented (matlab=matrix laboratory, I think) so my program in scilab would be, in one line:
    Code:
    T=5;N=200;plot((0:N)*T/N,sqrt(T/N)*cumsum([0;rand(N,1,'normal')]));
    (cumsum gives the cumulated sum of a vector : [X(1), X(1)+X(2), ...], very convenient)
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Moo
    Moo is offline
    A Cute Angle Moo's Avatar
    Joined
    Mar 2008
    From
    P(I'm here)=1/3, P(I'm there)=t+1/3
    Posts
    5,618
    Thanks
    6
    I trust you lol. It has been one year since we wrote this, and we just copied what the teacher wrote
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Brownian motion
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: September 23rd 2009, 03:42 PM
  2. Brownian Motion Help
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: May 13th 2009, 11:13 AM
  3. help with Brownian Motion
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: September 28th 2007, 06:32 PM
  4. Brownian Motion
    Posted in the Advanced Statistics Forum
    Replies: 3
    Last Post: April 8th 2007, 10:18 PM
  5. brownian motion
    Posted in the Advanced Applied Math Forum
    Replies: 5
    Last Post: February 27th 2007, 03:18 AM

Search Tags


/mathhelpforum @mathhelpforum