random integer between 0 and 15 with equal probability
Mostrar comentarios más antiguos
Hi,
I am trying to generate a random integer between 0 and 15.
I have written the following code:
b=0;
B=15;
B = b + (B-b) * rand
Is it right?
Also, will the random integer generated from the above code have equal probability? Is not, how should the code be modified?
Respuesta aceptada
Más respuestas (2)
Azzi Abdelmalek
el 15 de Jul. de 2013
B1= ceil(b + (B+1-b) * rand)-1
1 comentario
Syed
el 15 de Jul. de 2013
Jan
el 15 de Jul. de 2013
This is not a hard proof, but a strong hint already:
b = 0;
B = 15;
R = b + (B-b) * rand(1, 1e6);
histc(R, unique(R))
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!