Normal random numbers
R = distfun_normrnd ( mu , sigma ) R = distfun_normrnd ( mu , sigma , [m,n] ) R = distfun_normrnd ( mu , sigma , m , n )
a n-by-m matrix of doubles, the average
a n-by-m matrix of doubles, the standard deviation. sigma>0.
a 1x1 matrix of floating point integers, the number of rows of R
a 1x1 matrix of floating point integers, the number of columns of R
a matrix of doubles, the random numbers.
Generates random variables from the Normal distribution function.
Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.
// Set the seed so as to always get the same results. distfun_seedset(1); // Test both mu and sigma expanded computed = distfun_normrnd(1:6,(1:6)^-1) // Test sigma expansion computed = distfun_normrnd(1:6,2.0) // Test mu expansion computed = distfun_normrnd(1.0,1:6) // Test with v computed = distfun_normrnd(0,1,[3 2]) // Test with m, n computed = distfun_normrnd(0,1,3,2) // Make a plot of the actual distribution of the numbers mu = 2; sigma = 3; data = distfun_normrnd(mu,sigma,1,1000); scf(); histplot(10,data) x = linspace(-10,10,1000); y = distfun_normpdf(x,mu,sigma); plot(x,y) xtitle("Normal Random Numbers","X","Density") legend(["Empirical","PDF"]); | ![]() | ![]() |