Re: [R] Markoc chain simulation of a sample path - to get empirical probabilities

2014-05-16 Thread Jim Lemon
On Thu, 15 May 2014 10:03:03 AM chantel777 wrote: Dear Chantel, The problem: A perplexed student decides to post her/his (note non-sexist usage) homework to the R help list on a Friday evening. On Monday morning, she finds that she/he has received five different answers. Realizing that

[R] Markoc chain simulation of a sample path - to get empirical probabilities

2014-05-15 Thread chantel7777777
The question: A computer store sells iPods. If at the end of the day they have 0 or 1 unit of stock, they order enough new units so that their total number of units on hand is 5. New merchandise arrives before the store opens the next day. Demand each day is random with the following distribution

Re: [R] Markoc chain simulation of a sample path - to get empirical probabilities

2014-05-15 Thread Rolf Turner
(1) This list is *NOT* for helping people with homework. (2) Your code is kludgy, inefficient, and apparently wrong. (3) Think about what is going to happen in your very first call to sample() --- it will be: sample(6,1,prob=P[path[5],]) (Note that replace=TRUE is unnecessary and