jeudi 27 octobre 2016

Generating random numbers with weighted distribution in Matlab?

I know how to generate random numbers in a certain range in Matlab. What i am trying to do now is generate random numbers in a range where there is more chance of getting certain ones.

For example: how could i use Matlab to generate random numbers between 0 and 2, where 50% of them will be less than 0.5?

To get numbers between 0 and 2 I would use (2-0)*rand+0. How can i do this but get a certain percentage of the numbers generated to be less than 0.5? Is there a way to do this using the rand function?




Aucun commentaire:

Enregistrer un commentaire