|
Random
Random[
] gives a uniformly distributed pseudorandom Real in the range 0 to 1. Random[
type
,
range
] gives a pseudorandom number of the specified type, lying in the specified range. Possible types are: Integer, Real and Complex. The default range is 0 to 1. You can give the range
min
,
max
explicitly; a range specification of max is equivalent to
0,
max
.
Random[Integer] gives 0 or 1 with probability . Random[Complex,
zmin
,
zmax
] gives a pseudorandom complex number in the rectangle defined by zmin and zmax. Random[Real,
range
,
n
] generates an n-digit pseudorandom real number. Both leading and trailing digits may be chosen as 0. Random gives a different sequence of pseudorandom numbers whenever you run Mathematica. You can start Random with a particular seed using SeedRandom. See the Mathematica book: Section 1.1.3, Section 3.2.3. See also Implementation NotesA.9.44.5MainBookLinkOldButtonDataA.9.44.5. See also: $RandomState. Related packages: Statistics`ContinuousDistributions`, Statistics`DiscreteDistributions`.
Further Examples
This generates a random integer in the range from 1 to 100.
In[1]:= 
Out[1]= 
Here is a random real number in the range from 0 to 10.
In[2]:= 
Out[2]= 
Here is a random real number in the range from 0 to 1.
In[3]:= 
Out[3]= 
If you want to use a different distribution to generate random numbers, then you have to first load the package ContinuousDistributions.m.
In[4]:= 
Then, to generate random numbers with a log normal distribution, for example,
In[5]:= 
LogNormalDistribution[mu, sigma] represents the log-normal distribution with mean parameter mu and variance parameter sigma.
In[6]:= 
In[7]:= 
Out[7]= 
If you need repeatable results, you can reseed the random number generator.
In[8]:= 
In[9]:= 
Out[9]= 
In[10]:= 
In[11]:= 
Out[11]= 
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT. SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION. | |