I used a function to assign the value of p as per my choice. Inside the function I used the inbuilt function randsrc() to get a matrix of desired order and to generate the index value with a user defined probability. For example, to get a matrix of order 1X10 and to generate 1 with a probability of 0.7, I used randsrc(1,10,[1 0;0.7 0.3]). The first output was alright as i got 7 1's and 3 0's but when i ran it a multiple times, the output was not the same as probability of generation of 1's was not as per my desire. Can you please point out why or suggest a better approach to solve the question?
Aucun commentaire:
Enregistrer un commentaire