random( )
|
A random number between 0 and 1 drawn from a uniform distribution.
|
random(max)
|
A random (real) number between 0 and max drawn from a uniform distribution.
|
random(min, max)
|
A random (real) number between min and max drawn from a uniform distribution: random(-10, 10) returns a number between -10 and 10.
|
randomInteger(min, max)
|
A random integer between its two arguments, inclusive. With no arguments, it returns either 0 or 1 with equal probability. With one argument, it returns an integer between 0 and the value of the argument: randomInteger(1, 6) gives 1, 2, 3, 4, 5, or 6, chosen at random, such that each integer has equal probability.
|
randomPick(a1, a2, ... )
|
Gives an element randomly chosen from a list of any number of arguments:
randomPick(1, 2, 3, 4, 5, 6) makes a die.
randomPick("heads", "tails") makes a coin.
randomPick("Male", "Male", "Female") gives you a population that is two-thirds male.
|
randomBinomial(n, p) n = number of trials
p = probability of success
|
Gives a random integer from a binomial distribution: randomBinomial(20, 0.5) gives the number of heads in 20 tosses of a fair coin.
Two optional arguments provide a minimum and maximum value:
randomBinomial(5,0.5,1,2) draws numbers from a binomial distribution and scales them so that the possible results are 1.0, 1.2, 1.4, 1.6, 1.8, and 2.0.
|
randomNormal(mu, sd) mu = the mean
sd = standard deviation
|
A random real number pulled from a normal distribution. For example, randomNormal(0, 1) gives a number from a distribution with a mean of 0 and a standard deviation of 1.
|
randomGeometric(p) p = the probability of a "catch." Must be between 0 and 1.
|
A random nonnegative integer from a geometric distribution. Think of the result as the number of repetitions of some event before the result is positive given that the probability of that positive outcome is p.
Example: randomGeometric(0.5) generates the distribution of additional flips of a coin necessary to get a head. Two additional parameters to the function help here. randomGeometric(p, scale, min) has possible values min, min + scale, min + 2*scale, and so on.
So, randomGeometric(0.5, 1, 1) generates the distribution of the number of coin flips needed to get a head.
|
randomExponential(mu) mu = the mean and must be positive.
|
A random real number greater than zero, pulled from a distribution that declines exponentially (so there are more near zero, just as in the geometric distribution): randomExponential(5)min would be for simulating times between customers when the average time between customers is known to be 5 minutes.
A second, optional argument specifies the minimum value returned. randomExponential(mu, min) will have a mean of mu + min.
|