2.1.24.8.15 normrnd


Description

Generates an array of random numbers from a Normal distribution, seeds and generator number passed explicitly

Syntax

int normrnd( double * v, uint n, double xmu, double var )

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
xmu
[input] The mean, ??, of the distribution
var
[input] The variance, s2, of the distribution

Return

Return NE_NOERROR(0) on success, otherwise error.

Examples

EX1

//This example is to generate pseudo-random numbers from a Normal distribution
int normrnd_ex1()
{
	uint n = 10; 
	vector v(n);
	double xmu = 1.0;
	double var = 1.5;

    int nRet = normrnd( v, n, xmu, var);
 
    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

mvnrnd

Header to Include

origin.h

Reference