I want to generate geometric or Gaussian distributed random numbers without using "geornd" or "randn" functions present in MATLAB library. How can I generate random numbers with those distributions by using only the "rand" function used to generate uniformly distributed random numbers. I want to do this because Uniform distribution is the most basic type distribution and any other distribution can be generated from this distribution. A small code example would be very helpfull..!!
Asked
Active
Viewed 792 times
-4
-
2I don't fully understand your rationale - the `geornd` function (and probably `randn` too) already uses the `rand` function to produce a result - so are you basically saying you just want to re-implement them yourself? – devrobf Aug 19 '13 at 12:04
-
as @ jazzbassrob points out, if you have the stats toolbox check out the code for geornd: `edit geornd` – Buck Thorn Aug 19 '13 at 12:41
-
You may be interested in [this matlab page](http://www.mathworks.com/company/newsletters/articles/normal-behavior.html) explaining the algorithm used for generating normal values (matlab changed the algorithm in v.6). – marsei Aug 19 '13 at 12:47
1 Answers
0
I suppose you can do this:
U = rand(1)
mu = 5;
sigma = 3;
N = mu + sigma * norminv(U,1,1)

Dennis Jaheruddin
- 21,208
- 8
- 66
- 122