Two input numbers random generation

1 visualización (últimos 30 días)
Nikolay Panasetsky
Nikolay Panasetsky el 6 de Dic. de 2015
Comentada: Nikolay Panasetsky el 6 de Dic. de 2015
Hello.
How can I randomly generate just two input numbers, for example: 1 or 3; 0.95 or 1.05 ?
  1 comentario
Stephen23
Stephen23 el 6 de Dic. de 2015
What range? What distribution? What precision?

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Dic. de 2015
If you are trying to randomly generate from a set of distinct numbers, then you can use randsample() if you have the Statistics Toolbox. If you do not then see the File Exchange such as http://www.mathworks.com/matlabcentral/fileexchange/21912-sampling-from-a-discrete-distribution
In the simplest form of equal weight, to draw N times from two values stored in Samples,
Samples( 1 + (rand(1,N) > 1/2) )

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by