Using "rand" to randomize percent probability between two numbers
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
lauuser1
el 10 de Abr. de 2016
Respondida: Image Analyst
el 10 de Abr. de 2016
How would you write a code to do these probabilities? These probabilities are all related, so for example it would mean one helicopter has all of these probabilities to rise or fall a certain meter.
50% probability between 0m to 25m
10% probability between 25m to 50m.
5% probability between 50m to 75m.
20% probability between 0m to 50m.
10% probability between 50m to 150m.
5% probability between 150m to 200m.
There is an equal probability of any value between the two values.
0 comentarios
Respuesta aceptada
Image Analyst
el 10 de Abr. de 2016
Do you mean like this:
r = rand;
if r < .5
% 50% probability between 0m to 25m
elseif r < 0.6
% 10% probability between 25m to 50m.
elseif r < 0.65
% 5% probability between 50m to 75m.
elseif r < 0.85
% 20% probability between 0m to 50m.
elseif r < 0.95
% 10% probability between 50m to 150m.
else
% 5% probability between 150m to 200m.
end
You get a random number and then test it. You will go into the respective blocks of the "if" with the designated probabilities. Then inside the block you can do whatever you want, such as set the altitude or change in altitude or whatever.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Hypothesis Tests en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!