Skip to content
Back to formatted view

Raw Message

Message-ID: <74a4e5081001130920h3015d155r87ab4ab40f349c6c@mail.gmail.com>
Date: 2010-01-13T17:20:46Z
From: Kelvin
Subject: Simulation numbers from a probability table

Dear friends,

If I have a table like this, first row A B C D ... are different
levels of the variable, first column 0 1 2 4 ... are the levels of the
"numbers", the numbers inside the table are the probabilities of the
"number" occuring.

    A      B      C       D    ...
0  0.2    0.3    0.1    0.05
1  0.1    0.1    0.2    0.2
2  0.02  0.2    0       0.1
4  0.3    0.01  0.01   0.4
...

How can I use R to do the simulation and get a table like this, first
row A B C D ... are different levels of the variable, the numbers
inside the table are the "numbers" simulated from the probailties
table above?

    A  B  C  D ...
    0  4   2   0
    2   2  0   1
    0   1  4   1
    2   2  0   0
    ...


    Thanks for help!


    Kelvin