How to generate random numbers between two negative or one negative and one positive number?
32 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Khush
am 26 Jan. 2019
Bearbeitet: Khush
am 26 Jan. 2019
The random generation should fall under normal or poisson distribution.
I have been trying to generate a set of 100 new numbers from previous 10 numbers. The new numbers generated must fall near 2 to 3 deviations from the mean. The problem is that when I have negative numbers, the random function gives me NaN number. It is important for me to keep those negative numbers for the generation since they are a result of a previous calculation in the code. Do we have another way to go about this? All suggestions are highly appreciated. Thanks in advance
1 Kommentar
Stephen23
am 26 Jan. 2019
"The problem is that when I have negative numbers, the random function gives me NaN number"
Which "random function" are you talking about?
In a new comment, please show us the exact code that you tried.
Akzeptierte Antwort
Andrey Kiselnikov
am 26 Jan. 2019
Bearbeitet: Andrey Kiselnikov
am 26 Jan. 2019
Hi, X = rand returns a single uniformly distributed random number in the interval (0,1). Then you can multiply it and add constants.
For example, X = rand*2 -1; will return random number between (-1,1).
0 Kommentare
Siehe auch
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!