I have a support (supp_epsilon
) and a probability mass function (pr_mass_epsilon
) in Matlab, constructed as follows.
supp_epsilon=[0.005 0.01 0.015 0.02];
suppsize_epsilon=size(supp_epsilon,2);
pr_mass_epsilon=zeros(suppsize_epsilon,1);
alpha=1;
beta=4;
for j=1:suppsize_epsilon
pr_mass_epsilon(j)=betacdf(supp_epsilon(j),alpha,beta)/sum(betacdf(supp_epsilon,alpha,beta));
end
Note that the components of pr_mass_epsilon
sum up to 1
. Now, I want to draw n
random numbers from pr_mass_epsilon
. How can I do this? I would like a code that works for any suppsize_epsilon
.
Aucun commentaire:
Enregistrer un commentaire