My Math Forum  

Go Back   My Math Forum > Math Forums > Math Software

Math Software Math Software - Mathematica, Matlab, Calculators, Graphing Software

LinkBack Thread Tools Display Modes
March 12th, 2007, 03:04 PM   #1
Joined: Mar 2007

Posts: 2
Thanks: 0

Random Walks - Matlab

Hi! (Not sure if this is the right forum but...)
I need to create a program in Matlab that produces a random walk.
Basically I'm investigating whether random walks can be used to model
share prices; in my research I've found that there are two arguments
for which distributions share prices follow (although I guess these
may not always be true in practice). The possibilites are either a
normal distribution or a t-distribution. So I need to produce 2 walks
and in each I want the changes in the random walk (share price) to
reflect the distribution of choice. Is this possible? I would be
greatful for any help.
Prior to this I've been using the following program to produce a
random walk not based on these distributions; but I'm not sure how to
move on...

function y = randomwalk(x0,p,nsteps)

y(1:nsteps) = 0;
y(1) = x0;
for istep = 2:nsteps
y(istep) = y(istep-1) + step(p);

function y = step(p)

y = 1;
if ( rand() < 1-p )
y = -1;

%% Generate and plot a random walk
x = randomwalk(0,0.5,10000);

Key-J is offline  

  My Math Forum > Math Forums > Math Software

matlab, random, walks

Search tags for this page
Click on a term to search for related topics.
Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Matlab Help! Abhimint Math Software 0 January 26th, 2013 06:47 PM
Random walks in hyperspace david188288 Advanced Statistics 0 January 7th, 2012 09:58 AM
Hello! I like infinite walks on the coastline ;) chalee New Users 7 January 3rd, 2010 11:05 PM
Random Walks - Matlab Key-J Advanced Statistics 0 December 31st, 1969 04:00 PM
Random Walks - Matlab Key-J Computer Science 0 December 31st, 1969 04:00 PM

Copyright © 2019 My Math Forum. All rights reserved.