BernoulliNoise
- Updated2023-02-21
- 2 minute(s) read
BernoulliNoise
Advanced Analysis Library Only
AnalysisLibErrType BernoulliNoise (ssize_t numberOfElements, double probability, int seed, int initialize, int bernoulliNoise[]);
Purpose
Generates an array containing a pseudorandom pattern of ones and zeros. LabWindows/CVI computes each element of bernoulliNoise as if flipping a coin weighted by probability. The following equation defines the probability density function of the bernoulliNoise:
P(X = i) = pi(1 – p)1 – i (i = 0, 1)
where p is the probability. If probability is 0.7, each element of bernoulliNoise has a 70% chance of being one and a 30% chance of being zero. Bernoulli noise is a special case of Binomial noise.
The following equations define the mean value, µ, and the standard deviation value, σ, of the pseudorandom sequence:
µ = E{x} = p
Example Code
/* The following code generates an array of Bernoulli-distributed pseudorandom numbers. */
int x[20];
double oneprob;
int n;
n = 20;
oneprob = 0.8;
BernoulliNoise (n, oneprob, 17, TRUE, x);
Parameters
Input | ||
Name | Type | Description |
numberOfElements | ssize_t | The number of elements to generate in the Bernoulli-distributed pseudorandom pattern. |
probability | double | The probability of a given element of bernoulliNoise being true (1). probability must be 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, BernoulliNoise uses seed as follows:
|
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 |
bernoulliNoise | int [] | The output array containing the generated Bernoulli-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