# Random number generator based on probability distribution

1) What are the formulas for function 'random' and 'wblrnd' to generate the random numbers? assuming that I need these formula for coding in C++.

2) What are the differences between random numbers generated from function 'random' and 'wblrnd' for Weibull distribution?

3) It seems that MATLAB only supported 'random' function for Log Logistic Distribution. Is there any other formula to generate random numbers for Log Logistic Distribution? assuming that I need this formula for coding in C++

-

A bunch of things. First we work on getting a random number uniformly distributed in the interval [0,1]. Then we can use this PRNG (pseudo random number generator) to get whatever else we need may it be random integers or random real numbers (even complex numbers actually) in whatever range under whatever distribution we want. That part is easy. The first part is hard.

Depending on how many numbers you need (like are we talking about a total of 100 or billions upon billions?) and depending on what kind of quality are you looking for (is it just for a small simulation or a game or are you looking for good cryptographic strength?), there are a LOT of methods available. As the quality goes up they get harder to code (properly I mean) and slower. Is there a particular reason you want to write your own? Because there are plenty of good libraries already out there in every language which already have all the details worked out with pretty sophisticated and efficient/fast implementations which it would hard for me, you, or anyone else to beat. Here is a list of all the well known ones. You can look here and implement your own or once you find the one you like just google it plus your favorite language.

The second link here just talks a bit more about PRNGs and the last section also tells you how to go from the first step to the second step to get pseudo-random numbers with whatever distribution you want. Basically you take the distribution's probability density function, find its cumulative distribution function, take the CDF's inverse and then run a uniformly distributed random number through it. Depending on the specific distribution, this can get ugly. And for specific distribution (like Gaussian) there are other faster methods.

MATLAB has a bunch of different methods for uniform distribution and you can specify which one you want. And from what I remember they only have uniform and normal distributions built-in (rand and randn).

-
Thank you for sharing. – Sata Mar 7 '13 at 7:47
If you like my answer, feel free to upvote it (by clicking the up-arrow to the left of my answer) and acccepting it (by clicking the checkmark to the left of my answer) :-) – Fixed Point Mar 7 '13 at 7:58
Thank you for sharing about random numbers. Please explain and help me to understand more about probability distribution. My questions are: given a list of probability distribution, how to differentiate the functionality and purposes of each distribution? What are the applications and when to use each distribution? Where can I get simple examples for the distribution. For instance, what is the difference between the random numbers generated through Laplace distribution, Log Logistic distribution or Power distribution? – Sata Mar 7 '13 at 8:04
Which distribution do you need? Random number generated with a certain distribution means that if you take many many of them and plot its histogram, it will look like the probability distribution function of that distribution. – Fixed Point Mar 7 '13 at 8:40
To answer your other questions, there are A LOT of distributions so look here en.wikipedia.org/wiki/List_of_probability_distributions and then click on the ones you are interested in, to learn more about them. – Fixed Point Mar 7 '13 at 8:42