[R] Monte Carlo simulation in R
(Ted Harding)
Ted.Harding at manchester.ac.uk
Wed Mar 24 11:20:24 CET 2010
On 24-Mar-10 01:05:56, 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%
>
> 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 will need to state (and probably formulate) the problem better.
You have presented your "matrix" as a single line of 5 blocks of 3.
25% 30% 10% 30% 20% 0% 20% 50% 60% 50% 0% 10% 20% 0% 20%
It is ambiguous as to whether a block of 3 is a row or a column.
So this could represent
Person = 1 2 3
----------------------
Zone = 1 25% 30% 10%
2 30% 20% 0%
3 20% 50% 60%
4 50% 0% 10%
5 20% 0% 20%
in which Person=1 and Zone=3 gets 30% (as you state).
Or it could represent
Person = 1 2 3 4 5
------------------------------
Zone = 1 25% 30% 20% 50% 20%
2 30% 20% 50% 0% 0%
3 10% 0% 60% 10% 20%
Once again, Person=1 and Zone=2 gets 30%. So your example does
not identify which of these two representations is the one
you intend.
I suspect you mean the first, since in that you have columns
2 and 3 adding up to 100% (which, as probabilities over the
choices each Person could make, they have to do), and this
does not occur for any column of the second. But column 1 in
the first does not add up to 100% -- so what would you then
mean by the percentages in column 1? Or do you intend an
interpretation of your statement according to which the
percentages in the columns do not represent probabilities
which add to 1?
In that case, the second representation could also be valid.
But then what do your percentages mean?
More details, please!
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 24-Mar-10 Time: 10:20:22
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list