vendredi 6 avril 2018

Sample a number from 0 to 1 with uneven probabilities

I would like to sample a random number between 0 and 1, with an 90% probability to sample from 0-0.3 and 10% to sample between 0.3-1.

I tried the following:

0.9*runif(1, 0, 0.3) + 0.1*runif(1, 0.3, 1)

But that's not quite it: I will never get the number 0.8, for example.

Is there a simple way to do it in Base R?




Aucun commentaire:

Enregistrer un commentaire