mardi 10 mars 2015

Generate uniformly distributed random numbers between [a b] which occur with probablity c uniformly?

I want to generate random number between [a b] which is uniformly distributed and occur with probability of c uniformly.


I have one approach



x = rand(1,n);
y = zeros(1,n);
for i = 1:n
if x(i) > 1-c
y(i) = rand()*(b-a)+a;
end
end


But I am not sure whether it is correct or not.





Aucun commentaire:

Enregistrer un commentaire