mercredi 8 juillet 2020

How can i create a sequence where the symbols have different probabilities? [duplicate]

I have 4 symbols 0,1,2,3 . How can i create a sequence with these symbols where every symbol should have each own probabilty .

For example i want the symbols 1,2 to appear with probability q , but in the other hand the symbols 1,4 to appear with probability (1-q)/2.

In my last excersice i was asked to create a sequence where these symbols have the same probability 1/4 so i wrote the code below:

C = floor(rand(1,n)*4);

But i am little confused about this issue .Any help would be valuable.




Aucun commentaire:

Enregistrer un commentaire