How to generate realisations from two sets
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have two sets,e.g., S1={1,2,3,4} and S2={1,2,3,4,5}. I want to pick up 2 numbers randomly from S1 and 3 numbers from S2. Note that the order of the 2 or 3 picked numbers is not important. Theoretically, the probability that a number will appear in both sets is 2/4*3/5=6/20 (Am I correct?). I want to prove this using matlab by generating a large number of realizations and check the distribution.
0 commentaires
Réponses (1)
the cyclist
le 28 Août 2019
Modifié(e) : the cyclist
le 28 Août 2019
L1 = length(S1);
N1 = 2;
S1(randperm(L1,N1))
will choose N1 numbers (in this case, 2) from S1. You can choose similarly from S2.
Regarding your probability estimate ...
You cannot say in general that the probability of appearing in both sets is 6/20. What if S1 and S2 have no numbers in common?
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!