2.1.24.8.14 nbinrnd


Description

Generates an array of random integers from a negative binomial distribution, seeds and generator number passed explicitly

Syntax

int nbinrnd( long * v, uint n, int m, double p )

Parameters

v
[output] Pointer to a double array, which contain the results
n
[input] The number of pseudo-random numbers to be generated. n>=1
m
[input] The number of fialures, m, of the distribution
p
[input] The parameter p of the negative binomial distribution representing the probability of success at a single trial

Return

Return NE_NOERROR(0) on success, otherwise error.

Examples

EX1

//This example is to generate pseudo-random numbers from negative binomial distribution
int nbinrnd_ex1()
{
	uint n = 20; 
	long v[20];
	double p = 0.99;
	int m = 60;

    int nRet = nbinrnd( v, n, m, p);
 
    if(0 != nRet)
    	return 0;
    
    for(int i=0;i<n;i++)
        printf("v[%d]: %d\n",i, v[i]);

    return 1;
}

Remark

See Also

mvnrnd

Header to Include

origin.h

Reference