I searched everywhere for an answer but could not find any, so I hope someone here could help me out.
I have a vector where each entry is a given probability from 0 to 1.
What I need is a function/way to create a new dummy vector with values 0 or 1 where the probability of having a 1 is given by the probability of the line of the other vector.
That is: if in probability-vector I have an entry with 0.5 I need to have a corresponding cell equal to 1 (almost) half of the time over 100 repetitions of this function.
Something like the table below
Probability | iter1 | iter2 | iter3 | iter4 | iter5 | iter6 | iter7 | iter8 | iter9 | iter10 |
0.5 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
Do you know how I could achieve something like this?
please let me know if the question is not clear enough
Thank you all,
D.
0 Response to How draw a number from a given vector of distribution?
Post a Comment