My Math Forum  

Go Back   My Math Forum > Math Forums > Math Software

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


Reply
 
LinkBack Thread Tools Display Modes
March 12th, 2007, 04:04 PM   #1
Newbie
 
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);
end

function y = step(p)

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

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

Thanks!!
Key-J is offline  
 
Reply

  My Math Forum > Math Forums > Math Software

Tags
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 07:47 PM
Random walks in hyperspace david188288 Advanced Statistics 0 January 7th, 2012 10:58 AM
Hello! I like infinite walks on the coastline ;) chalee New Users 7 January 4th, 2010 12:05 AM
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 © 2018 My Math Forum. All rights reserved.