How can I choose an element from a vector according to its probability ?
Afficher commentaires plus anciens
I want to select an angle according to the probability. I executed the code below its show me the only FIRST option (only 10 even when I change the probability value its show me the same option). Thank in advance for any help
t=0.1;Ang_1 = [10 20 30 45 80];% this vector of options
for i:1:1
prob = (exp((1/t)*1.2*10^-5))./(exp((1/t)*1.2*10^-4)) % this is probability could be changable each eteration
select = Ang_1(find(rand<cumsum(prob),1)) % select angle according to "prob"
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Probability Density Functions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!