Why rand function is not uniform in large intervals?
Mostrar comentarios más antiguos
I am using rand function to generate uniformly distributed random numbers in the interval [10e-6 and 1.] But the function generates the nos. which are close to 1 (RATHER THAN BEING UNIFORM IN THE ENTIRE INTERVAL]. I have tried with 10 nos. and 100 nos. But I found that most the nos. generated are close to 1. Then, how it will be a uniform distribution??
3 comentarios
Walter Roberson
el 23 de Jun. de 2016
Please show your code.
Adam
el 23 de Jun. de 2016
rand always generates numbers between 0 and 1. What you then do with those to get them into a range you are interested in is entirely up to you.
John D'Errico
el 23 de Jun. de 2016
Rand IS uniform, and it generates numbers in the range from 0 to 1. If you are mis-using the results of rand in some way, then expect strange results. So show what you wrote.
Respuesta aceptada
Más respuestas (2)
Roger Stafford
el 26 de Jun. de 2016
Editada: Roger Stafford
el 26 de Jun. de 2016
It seems clear from his most recent comment that where Pankaj says “uniform” he actually means a "logarithmic" distribution where there would be as many samples in the interval [10^(-6),10^(-5)] as in the interval [10^(-1),10^(0)], and indeed in any interval [10^(-k),10^(-k+1)], -6<=k<=-1. If that is the case, the proper code would be:
r = 10.^(-6*rand(1,n));
1 comentario
Roger Stafford
el 26 de Jun. de 2016
Oops! I didn't notice the same answer given by John earlier on.
pankaj singh
el 27 de Jun. de 2016
0 votos
Categorías
Más información sobre Uniform Distribution (Continuous) 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!
