Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
How do I find the probability that 0 would be selected if a random number was selected?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
d = [1, 0.5, 0.01, 0.5, 0, 1, 2, 15.31, 33, 12, 3, 7, 2, 15, 38, 0, ...
2.5, 0, 0.4, 17.8, 0.5, 10.6, 0, 0.1, 11, 12, 1, 0.8, 0, 7, 10, ...
0, 10.1, 4.14, 0.5, 14.7, 0, 0, 0, 0, 0.1, 0. 37, 3.1, 25, 0, 1, ...
1.4, 7.5, 17.9, 30, 0, 0, 0, 14.2, 30, 23.7, 0, 0, 0, 7.7, 3.4, 0, ...
0, 0, 0, 0, 0, 0, 0.5, 0, 11, 0, 10, 0, 0, 70, 0, 15, 3.5, 9];
0 Commenti
Risposte (2)
Sarah Crimi
il 7 Feb 2019
d = [1, 0.5, 0.01, 0.5, 0, 1, 2, 15.31, 33, 12, 3, 7, 2, 15, 38, 0, ...
2.5, 0, 0.4, 17.8, 0.5, 10.6, 0, 0.1, 11, 12, 1, 0.8, 0, 7, 10, ...
0, 10.1, 4.14, 0.5, 14.7, 0, 0, 0, 0, 0.1, 0. 37, 3.1, 25, 0, 1, ...
1.4, 7.5, 17.9, 30, 0, 0, 0, 14.2, 30, 23.7, 0, 0, 0, 7.7, 3.4, 0, ...
0, 0, 0, 0, 0, 0, 0.5, 0, 11, 0, 10, 0, 0, 70, 0, 15, 3.5, 9];
%create a counter to count the number of zeros
counter=0;
%Create a loop to add 1 each time there is another 0.
for i=1:length(d)
if(d(i)==0)
counter = counter+1;
end
end
Kevin Phung
il 7 Feb 2019
Modificato: Kevin Phung
il 7 Feb 2019
Just do:
d = [1, 0.5, 0.01, 0.5, 0, 1, 2, 15.31, 33, 12, 3, 7, 2, 15, 38, 0, ...
2.5, 0, 0.4, 17.8, 0.5, 10.6, 0, 0.1, 11, 12, 1, 0.8, 0, 7, 10, ...
0, 10.1, 4.14, 0.5, 14.7, 0, 0, 0, 0, 0.1, 0. 37, 3.1, 25, 0, 1, ...
1.4, 7.5, 17.9, 30, 0, 0, 0, 14.2, 30, 23.7, 0, 0, 0, 7.7, 3.4, 0, ...
0, 0, 0, 0, 0, 0, 0.5, 0, 11, 0, 10, 0, 0, 70, 0, 15, 3.5, 9];
Probability = sum(d==0)/ numel(d);
0 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!