Table Of Contents

random

Version:
    Last Modified: March 15, 2017

    Generates random numbers according to a specified distribution.

    Syntax

    r = random(type, a, b, c)
    r = random(type, a, b, c, m)
    r = random(type, a, b, c, m, n)
    r = random(type, a, b, c, m, n, ...)

    Inputs

    type

    Type of distribution. type is a string that accepts the following values:

    Name Description
    'beta'

    Beta distribution. MathScript also accepts 'Beta'. This distribution requires the parameters a and b.

    'bino'

    Binomial distribution. MathScript also accepts 'Binomial'. This distribution requires the parameters a and b.

    'chi2'

    Chi-squared distribution. MathScript also accepts 'Chisquare'. This distribution requires the parameter a.

    'exp'

    Exponential distribution. MathScript also accepts 'Exponential'. This distribution requires the parameter a.

    'f'

    F distribution. MathScript also accepts 'F'. This distribution requires the parameters a and b.

    'gam'

    Gamma distribution. MathScript also accepts 'Gamma'. This distribution requires the parameters a and b.

    'geo'

    Geometric distribution. MathScript also accepts 'Geometric'. This distribution requires the parameter a.

    'hyge'

    Hypergeometric distribution. MathScript also accepts 'Hypergeometric'. This distribution requires the parameters a, b, and c.

    'logn'

    Lognormal distribution. MathScript also accepts 'Lognormal'. This distribution requires the parameters a and b.

    'nbin'

    Negative binomial distribution. MathScript also accepts 'Negative Binomial'. This distribution requires the parameters a and b.

    'ncf'

    Noncentral F distribution. MathScript also accepts 'Noncentral F'. This distribution requires the parameters a, b, and c.

    'nct'

    Noncentral T distribution. MathScript also accepts 'Noncentral T'. This distribution requires the parameters a and b.

    'ncx2'

    Noncentral chi-squared distribution. MathScript also accepts 'Noncentral Chisquare'. This distribution requires the parameters a and b.

    'norm'

    Normal distribution. MathScript also accepts 'Normal'. This distribution requires the parameters a and b.

    'poiss'

    Poisson distribution. MathScript also accepts 'Poisson'. This distribution requires the parameters a and b.

    'rayl'

    Rayleigh distribution. MathScript also accepts 'Rayleigh'. This distribution requires the parameter a.

    't'

    T distribution. MathScript also accepts 'T'. This distribution requires the parameter a.

    'unid'

    Discrete uniform distribution. MathScript also accepts 'Discrete Uniform'. This distribution requires the parameter a.

    'unif'

    Continuous uniform distribution. MathScript also accepts 'Uniform'. This distribution requires the parameters a and b.

    'weib'

    Weibull distribution. MathScript also accepts 'weibull'. This distribution requires the parameters a and b.

    a

    Parameter for the distribution. a is a number or an array. If a is an array, a must be of the size m-by-n-by-....

    b

    Parameter for the distribution. b is a number or an array. If b is an array, b must be of the size m-by-n-by-....

    c

    Parameter for the distribution. c is a number or an array. If c is an array, c must be of the size m-by-n-by-....

    m

    Number of rows in r. m is a positive integer.

    n

    Number of columns in r. n is a positive integer.

    ...

    Size of further dimensions. ... is a positive integer.

    Outputs

    r

    m-by-n-by-... array of random numbers with a type distribution.

    Syntax Variants

    • random(type, a, b, c) generates a single random number.
    • random(type, a, b, c, m) and random(type, a, b, c, n) generate an m-by-m and n-by-n matrix, respectively.
    • random(type, a, b, c, m, n) and random(type, a, b, c, [m, n]) generate an m-by-n matrix.
    • random(type, a, b, c, m, n, ...) and random(type, a, b, c, [m, n, ...]) generates an m-by-n-by-... array.

    Parameters for Distribution Types

    The input elements a, b, and c specify the following parameters for each of the distribution types:

    Distribution Type Specification of a and b
    beta a specifies the first shape parameter. b specifies the second shape parameter.
    bino (Binomial) a specifies the number of Bernoulli trials to perform. b specifies the probability that a given Bernoulli trial is true.
    chi2 (Chisquare) a specifies the number of degrees of freedom.
    exp (Exponential) a specifies the scale parameter.
    f (F) a specifies the number of degrees of freedom in the first chi-squared variate in the F distribution. b specifies the number of degrees of freedom in the second chi-squared variate in the F distribution.
    gam (Gamma) a specifies the scale parameter. b specifies the shape parameter.
    geo (Geometric) a specifies the probability parameter.
    hyge (Hypergeometric) a specifies the total number of elements in the population. b specifies the number of successes. c specifies the number of items drawn without replacement.
    logn (Lognormal) a specifies the scale or median parameter. b specifies the shape parameter.
    nbin (Negative Binomial) a specifies the number of Bernoulli trials to perform. b specifies the probability that a given Bernoulli trial is true.
    ncf (Noncentral F) a specifies the number of degrees of freedom of the noncentral chi-squared variate in the noncentral F distribution. b specifies the number of degrees of freedom of the chi-squared variate in the noncentral F distribution. b specifies the noncentrality parameter of the noncentral chi-squared variate in the noncentral F distribution.
    nct (Noncentral T) a specifies the number of degrees of freedom. b specifies the noncentrality parameter.
    ncx2 (Noncentral Chisquare) a specifies the number of degrees of freedom. b specifies the noncentrality parameter.
    norm (Normal) a specifies the location or mean parameter. b specifies the standard deviation parameter.
    poiss (Poisson) a specifies the mean parameter.
    rayl (Rayleigh) a specifies the scale parameter.
    t (T) a specifies the number of degrees of freedom.
    unid (Discrete Uniform) a specifies the amplitude parameter.
    unif (Uniform) a specifies the lower limit parameter. b specifies the upper limit parameter.
    weib (weibull) a specifies the location parameter. b specifies the shape parameter.
    R = random('chi2', 3, 5, 6)

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics