normal random number generator with specified zone

1 vue (au cours des 30 derniers jours)
milad babaei
milad babaei le 25 Fév 2011
Commenté : Mario Reutter le 22 Août 2018
Hi dear i have a problem with normal random number. generator.i need to use this generator for normally distribution but my related variable will be negative.so i need to restrict random numbers that generate by that between -1 and 1...could i have use uniform dist.instead of that with some mathematical change????please help me on that..

Réponses (2)

Andrew Newell
Andrew Newell le 25 Fév 2011
If a uniform distribution will do, you could try
rand*2-1
See documentation for rand for ways to generate vectors, matrices, etc.
  1 commentaire
Mario Reutter
Mario Reutter le 22 Août 2018
If "normal-distribution-like" properties are desired (symmetric and max density at center; but no points of inflection!):
betarnd(2, 2) * 2 - 1

Connectez-vous pour commenter.


the cyclist
the cyclist le 25 Fév 2011
Your question is not very clear, at least to me. It seems that you are asking for things that cannot all be true at the same time:
  • normally distributed
  • between -1 and 1
  • uniformly distributed
Also, you mention a "related variable," but's it's not clear what you mean by that.
So, I think you should try to provide a lot more detail about what you are trying to do, and what you want your distribution to look like. (A picture might help, if you can add one.)
Finally, many times when someone wants a distribution that is "sort of like a normal distribution" but has a finite range, they can use the beta distribution. The command in MATLAB is "betarnd".
  1 commentaire
milad babaei
milad babaei le 25 Fév 2011
tnx in advance,let me explain more about my case. i have 3 random variables.that every of that 3 related to a another(*) one(of course)its random too.i use normal distribution generator for monte carlo simulation in matlab to produce RAndom number.but in some cases with mention to unlimited zone of generating random number my final data(*)will be negative.that is not accurate and unexplainable for my job(bearing capacity-geotechnical eng.)i choose normally dist. because its the best match for my data and bell type format of its distribution also help me and i have to use it..also i need to generate positive random number with this normal dist.i think i should find a way to limit this generator to produce random number between -1 & 1 or even find a way to use this distribution with desirable mean and standard deviation..
with regards

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by