random (MathScript RT Module Function)

LabVIEW 2012 MathScript RT模块帮助

»查看产品信息 下载帮助（仅限Windows）

Owning Class: statistics

Requires: MathScript RT Module

Syntax

r = random(type, a, b, c)

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

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

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

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

Description

Generates random numbers according to a specified distribution. 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.

Details

Examples

Inputs

Name Description
type Specifies the type of distribution. type is a string that accepts the following values.

 'beta' Specifies a beta distribution. LabVIEW also accepts 'Beta'. This distribution takes two parameters. 'bino' Specifies a binomial distribution. LabVIEW also accepts 'Binomial'. This distribution takes two parameters. 'chi2' Specifies a chi-squared distribution. LabVIEW also accepts 'Chisquare'. This distribution takes one parameter. 'exp' Specifies an exponential distribution. LabVIEW also accepts 'Exponential'. This distribution takes one parameter. 'f' Specifies an F distribution. LabVIEW also accepts 'F'. This distribution takes two parameters. 'gam' Specifies a gamma distribution. LabVIEW also accepts 'Gamma'. This distribution takes two parameters. 'geo' Specifies a geometric distribution. LabVIEW also accepts 'Geometric'. This distribution takes one parameter. 'hyge' Specifies a hypergeometric distribution. LabVIEW also accepts 'Hypergeometric'. This distribution takes three parameters. 'logn' Specifies a lognormal distribution. LabVIEW also accepts 'Lognormal'. This distribution takes two parameters. 'nbin' Specifies a negative binomial distribution. LabVIEW also accepts 'Negative Binomial'. This distribution takes two parameters. 'ncf' Specifies a noncentral F distribution. LabVIEW also accepts 'Noncentral F'. This distribution takes three parameters. 'nct' Specifies a noncentral T distribution. LabVIEW also accepts 'Noncentral T'. This distribution takes two parameters. 'ncx2' Specifies a noncentral chi-squared distribution. LabVIEW also accepts 'Noncentral Chisquare'. This distribution takes two parameters. 'norm' Specifies a normal distribution. LabVIEW also accepts 'Normal'. This distribution takes two parameters. 'poiss' Specifies a Poisson distribution. LabVIEW also accepts 'Poisson'. This distribution takes two parameters. 'rayl' Specifies a Rayleigh distribution. LabVIEW also accepts 'Rayleigh'. This distribution takes one parameter. 't' Specifies a T distribution. LabVIEW also accepts 'T'. This distribution takes one parameter. 'unid' Specifies a discrete uniform distribution. LabVIEW also accepts 'Discrete Uniform'. This distribution takes one parameter. 'unif' Specifies a continuous uniform distribution. LabVIEW also accepts 'Uniform'. This distribution takes two parameters. 'weib' Specifies a Weibull distribution. LabVIEW also accepts 'weibull'. This distribution takes two parameters.
a Specifies a parameter for the distribution. a is a number or matrix. If a is a matrix, a must be of the size m-by-n. Refer to the Details section for more information about this parameter.
b Specifies a parameter for the distribution. b is a number or matrix. If b is a matrix, b must be of the size m-by-n. Refer to the Details section for more information about this parameter.
c Specifies a parameter for the distribution. c is a number or matrix. If c is a matrix, c must be of the size m-by-n. Refer to the Details section for more information about this parameter.
m Specifies the number of rows in r. m is a positive integer.
n Specifies the number of columns in r. n is a positive integer.

Outputs

Name Description
r Returns an m-by-n matrix of random numbers with a type distribution.

Details

The input elements a, b, and c specify the following parameters for each of the distribution types:
• 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.

The following table lists the support characteristics of this function.

 Supported in the LabVIEW Run-Time Engine Yes Supported on RT targets Yes Suitable for bounded execution times on RT Not characterized

Examples

R = random('chi2', 3, 5, 6)

﻿