On Mar 23, 2010, at 9:05 PM, Hongwei Dong wrote:

Hi, R-helpers,

I'm trying to use R to do a Monte Carlo simulation and need the help. What I
have is a matrix that consists of the probabilities for the persons to
choose zones. For example, in the matrix shown below, each column represents a person, and each row represents a zone. So, the probability that the first
person will choose the 2nd zone is 30%.

25% 30% 10%  30% 20% 0%  20% 50% 60%  50% 0% 10%  20% 0% 20%

As Alex Trebeck would say: Can you put that in the form of an R data object?


Based on this matrix, I want to locate the persons to zones based on the probability using a Monte Carlo method. The result I want to see is like
this:

0 0 0  0 0 0  0 1 1  1 0 0  0 0 0

Could anyone please give some help? Thanks.

You cannot specify what the result _will_ be and call the process simulation of results at the same time. The sample function should work for a vector. Why not use it?

--
David.


David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to