trirnd

 

Description

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

Syntax

int trirnd( double * v, uint n, double xmin, double xmax, double xmed )

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
xmin
[input] The end-point of the uniform distribution
xmax
[input] The end-point of the uniform distribution
xmed
[input] The median of the distribution

Return

Return NE_NOERROR(0) on success, otherwise error.

Examples

EX1

//This example is to generate pseudo-random numbers from a triangular distribution
int trirnd_ex1()
{
    int n = 10;
    vector v(n);
        double xmin = -1.0, xmax = 1.0, xmed = 0.5;
                                        
    int nRet = trirnd( v, n, xmin, xmax, xmed);
    
    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