stats(deprecated)/random - Help

Overview of the stats[random] Subpackage

 Calling Sequence stats[random][distribution](quantity, uniform, method) random[distribution](quantity, uniform, method)

Parameters

 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'

Description

 • 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.

Examples

Important: The stats package has been deprecated. Use the superseding package Statistics instead.

 > $\mathrm{with}\left(\mathrm{stats}\right):$

generate 20 numbers with the standard normal distribution

 > $\mathrm{stats}[\mathrm{random},\mathrm{normald}]\left(20\right)$
 ${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}$ (1)

This time, use the 'inverse' method

 > $\mathrm{stats}[\mathrm{random},\mathrm{normald}]\left(20,'\mathrm{default}','\mathrm{inverse}'\right)$
 ${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}$ (2)

Generate 20 numbers with the poisson[3] distribution, using a user specified generator.

 > $\mathrm{seed}≔1$
 ${\mathrm{seed}}{≔}{1}$ (3)
 > uniform_generator:=proc()   # not a very good generator    global seed;    seed:=irem(seed*11,101);    return(seed/101) end proc:
 > $\mathrm{random}[\mathrm{γ}[3]]\left(20,\mathrm{uniform_generator}\right)$
 ${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}$ (4)

Generators:

 > $\mathrm{P1}≔\mathrm{random}[\mathrm{γ}[3]]\left('\mathrm{generator}'\right):$
 > $'\mathrm{P1}\left(\right)'$10$  ${4.836469539}{,}{8.353178496}{,}{0.8580684291}{,}{2.259265671}{,}{3.450849282}{,}{2.692610073}{,}{6.645335655}{,}{8.029222668}{,}{1.963201340}{,}{3.851992359}$ (5) Generators of 15 digit numbers.  > $\mathrm{P2}≔\mathrm{random}[\mathrm{γ}[3]]\left('{\mathrm{generator}}_{15}'\right):$  > $'\mathrm{P2}\left(\right)'$10$
 ${3.72980590085895}{,}{1.34273823710794}{,}{2.94592957570767}{,}{0.547985385167043}{,}{3.75980063833647}{,}{1.77869024847795}{,}{2.92867095947213}{,}{7.52997082985958}{,}{3.35028281579760}{,}{3.35085086325255}$ (6)