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