<< scidemo_matrixeigshow Demonstration Toolbox scidemo_normpdf >>

Demonstration Toolbox >> Demonstration Toolbox > scidemo_normaldist

scidemo_normaldist

Plots the exact Normal function and random generated points.

Calling Sequence

scidemo_normaldist ( mu , sigma , nrandx , nhclass )

Parameters

mu :

a 1-by-1 matrix of doubles, the mean

sigma :

a 1-by-1 matrix of doubles, the variance

nrandx :

a 1-by-1 matrix of doubles, the number of generated random numbers

nhclass :

a 1-by-1 matrix of doubles, the number of classes in the histogram

xmin :

a 1-by-1 matrix of doubles, the minimum x

xmax :

a 1-by-1 matrix of doubles, the maximum x

Description

Computes the exact distribution function of the Normal (Laplace-Gauss) distribution function in the range [xmin,xmax] and draw it. Then generate nrandx points and draw the histogram with nhclass classes. Then plots the intervals [mu-n*sigma,mu+n*sigma] for n=1,2,3. In the legend, display the corresponding integrals approximated from the intg function.

The current function is a demonstration of the following functions.

The Normal distribution function definition is:

This implies that, if X is a random variable from the Normal distribution, the probability that X is inside the interval [a,b] is

The previous equality can be associated with the erf function, which satisfies the equality

where n=1,2,3,....

Examples

// Compare generated Normal random numbers with exact PDF.
mu = 10;
sigma = 5;
xmin = mu-6*sigma;
xmax = mu+6*sigma;
nrandx = 10000;
nhclass = 100;
scf();
scidemo_normaldist ( mu , sigma , nrandx , nhclass , xmin , xmax );
// Uses erf and compare with approximate computations
erf([1 2 3]/sqrt(2))

Authors

Bibliography

distfun/normpdf, 2009-2010 - DIGITEO - Michael Baudin, http://forge.scilab.org/index.php/p/distfun/source/tree/HEAD/macros/normpdf.sci

<< scidemo_matrixeigshow Demonstration Toolbox scidemo_normpdf >>