Overview of the stats[random] Subpackage
Calling Sequence
Parameters
Description
Examples
stats[random][distribution](quantity, uniform, method)
random[distribution](quantity, uniform, method)
distribution
-
numbers generated according to this distribution
quantity
(optional, default=1) either a positive integer indicating how many random numbers are required, or the keyword 'generator'
uniform
(optional, default = 'default') a procedure that generates uniformly distributed numbers one at a time, or the keyword 'default'
method
(optional, default = 'auto') one of the keywords 'auto', 'inverse', or 'builtin'
Important: The stats package has been deprecated. Use the superseding package Statistics instead.
The stats[random] subpackage provides random numbers with a given distribution.
The random subpackage provides filters that transform a uniformly distributed stream of random numbers to a stream that has the required distribution. The underlying uniform generator can be specified by the parameter uniform.
The seed of the default generator can be modified by using the function randomize().
Random number generators are obtained by specifying the keyword 'generator' as the parameter quantity. The number of digits (if it is not the default value given in Digits) in the generated numbers is indicated as an index to 'generator'. If randomize() is used, it must be done prior to creating the generators.
The uniform generator specified using the parameter uniform must return one number between 0 and 1. The parameter uniform allows the generation of independent streams of random numbers, provided independent uniform generators are used. It must be noted that the design of good uniform generators, independent of each other, is not an easy task. A randomly chosen random number generator will most likely be of poor quality.
The parameter method specifies by which method the number will be generated. If method is 'inverse' the uniform stream is transformed according to the icdf of a continuous distribution and according to the idcdf of a discrete distribution. If method is 'builtin' then a special purpose function for the required distribution is called. If method is 'auto' then random uses the 'builtin' method, if there is one. If the required special purpose function is not present, then use the 'inverse' method.
The distributions available under the 'inverse' method are all the distributions for which either stats[statevalf, icdf] or stats[statevalf,idcdf] exists.
The distributions available under the 'builtin' method are
beta
chisquare
fratio
gamma
normald
studentst
Each command in the stats[random] subpackage can be accessed by using either the long form or the short form of the command name in the command calling sequence.
with⁡stats:
generate 20 numbers with the standard normal distribution
statsrandom,normald⁡20
1.275676034,0.4761860895,−2.620054215,0.8547207946,−1.089001804,0.7165427597,−0.02996436194,1.330855643,−1.296345119,−0.4703304030,−0.7122630822,−0.08717900722,1.282253009,−1.683720686,0.3265473243,0.08179818206,0.2127564698,−0.7279468705,0.6855773709,−0.3760280554
This time, use the 'inverse' method
statsrandom,normald⁡20,default,inverse
0.2942905914,1.023730745,−0.07256069586,−0.2726670238,0.9797884030,−0.06456731317,−0.7584692928,−1.414509920,0.5848741507,0.1502221444,0.7052134613,−0.1760249535,1.114921264,1.111477077,1.837138817,−0.007014805706,0.1412349839,−0.3487795280,2.269571409,0.6290512530
Generate 20 numbers with the poisson[3] distribution, using a user specified generator.
seed≔1
uniform_generator:=proc() # not a very good generator global seed; seed:=irem(seed*11,101); return(seed/101) end proc:
randomγ3⁡20,uniform_generator
1.171878004,1.514461967,3.368200854,1.997566185,4.818133461,6.550753566,0.6309471660,3.556933956,3.761058678,2.869958271,3.026686005,1.117441781,3.623114178,1.001527868,3.492458052,4.230152601,4.063203183,1.911176304,2.259044006,3.691114038
Generators:
P1≔randomγ3⁡generator:
`$`⁡P1⁡,10
2.107905566,3.303122862,4.720333296,5.299448094,0.7922832000,1.344411035,2.137886591,1.536677252,7.561093506,1.768841412
Generators of 15 digit numbers.
P2≔randomγ3⁡generator15:
`$`⁡P2⁡,10
2.66124020339848,1.88408891085322,1.98050403996597,2.42429577275181,1.77948925497783,1.07659616941955,0.839162335726089,5.74341795680385,5.90614461553164,6.71869339148415
See Also
rand
randomize
Statistics
Statistics[Distribution]
stats(deprecated)[distributions]
Download Help Document