2.1.24.8.4 chi2rnd


Description

Generates an array of random integers from a chi-square (\chi^2) distribution, seeds and generator number passed explicitly

Syntax

int chi2rnd( double * v, uint n, int df )

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
df
[input] The number of degrees of freedom, v, of the distribution

Return

Return NE_NOERROR(0) on success, otherwise error.

Examples

EX1

//This example is to generate pseudo-random numbers from ??2 distribution
int chi2rnd_ex1()
{
    int n = 5, df=5;
    vector v( n );
                    
    int nRet = chi2rnd( v, n, df);
 
    if(0 != nRet)
    	return 0;
    
    for(int i=0;i<n;i++)
        printf("v[%d]: %f\n",i, v[i]);
 
    return 1;
}

Remark

See Also

Header to Include

origin.h

Reference