Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: Probability Date: Fri, 7 May 2010 19:08:04 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 27 Message-ID: <hs1oek$ai7$1@fred.mathworks.com> References: <hs1kd9$evs$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-05-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1273259284 10823 172.30.248.35 (7 May 2010 19:08:04 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 7 May 2010 19:08:04 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:633619 "Gema Olivarria" <gforgamgee@yahoo.com> wrote in message <hs1kd9$evs$1@fred.mathworks.com>... > Hi this is my 3rd time using matlab i need help with something really simple. Here's my problem: > > Start with point #1(i=1) whose coordinates are X(i)=0 and Y(i)=0. > > Calculate the coordinates of the nxt point according to the following rule: > > Randomly choose one of the following four events: A,B,C or D. > probability of A is 0.01; > probability of B is 0.06; > probability of C is 0.08; > probability of D is 0.85. > > The coordinates of the nxt pt are: > > If A occurred, X(i+1)=0, Y(i+1)=0.16Y(i); > If B occurred, X(i+1)=0.20X(i)-0.26Y(i), Y(i+1)=0.23X(i)+0.22Y(i)+1.6; > etc., > > My question is, how do i assign the probabilities to each of these functions? what syntax do i use? - - - - - - - - Urs has given you excellent advice, Gema. However, I am guessing that if I give you the following matlab code as a hint for part of your problem without any explanation whatever, then having to figure out how and why it works and just what role it will play in your problem, should give you an added motivation to do the studying he recommends. I hope I am right. r = rand; k = (r<=.85)+(r<=.85+.08)+(r<=.85+.08+.06)+1; Roger Stafford