LabWindows/CVI

Content Type
Programming Language
Current manual

BinomialNoise

BinomialNoise

Advanced Analysis Library Only

AnalysisLibErrType BinomialNoise (ssize_t numberOfElements, int trials, double trialProbability, int seed, int initialize, int binomialNoise[]);

Purpose

Generates an array containing a Binomially-distributed pseudorandom pattern of values that are the number of occurrences of an event, given the probability of that event occurring and the number of trials. The following equation defines the probability density function of the binomialNoise:

where numberOfElements is the number of trials, p is the trialProbability, and equals . To generalize, P(X = i) is the probability that i of the numberOfElements trials equals 1, and numberOfElementsi equals zero. When numberOfElements equals 1, the Binomial noise degenerates into Bernoulli noise.

The following equations define the mean value, µ, and the standard deviation value, σ, of the pseudorandom sequence:

µ = E{x} = np

Example Code

/* The following code generates an array of Binomially-distributed pseudorandom numbers. */
int x[20];
double trialprob;
int n, trials;
n = 20;
trials = 1;
trialprob = 0.5;
BinomialNoise (n, trials, trialprob, 17, TRUE, x);

Parameters

Input
Name Type Description
numberOfElements ssize_t The number of elements to generate in the Binomially-distributed pseudorandom pattern.
trials int The number of trials performed for each element of binomialNoise.

trials must be greater than or equal to 0.
trialProbability double The probability that a given trial is true.

trialProbability must be in the range [0, 1].
seed int The seed value used to generate the random number when initialize is a nonzero value.

If initialize is a nonzero value, BinomialNoise uses seed as follows:

  • When seed ≥ 0, BinomialNoise generates a new random sequence using the seed value you specify.
  • When seed < 0, BinomialNoise uses a random number to generate the internal seed state.
If initialize if 0, BinomialNoise ignores seed and generates the sequence as a continuation of the previously generated noise sequence.
initialize int Specifies whether to reseed the noise generator. Specify a nonzero value or select Yes in the function panel to initialize the internal seed state according to the value of seed. Specify 0 or select No in the function panel to resume producing noise samples as a continuation of the previously generated noise sequence.
Output
Name Type Description
binomialNoise int [] The output array containing the generated Binomially-distributed pseudorandom pattern.

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.

Additional Information

Library: Advanced Analysis Library

Include file: analysis.h

LabWindows/CVI compatibility: LabWindows/CVI 2012 and later

Was this information helpful?