you could fill an array with random numbers
with a Gaussian distribution and make a chart of that, see below. To make
an array with the "Bell" shape curve you need to get the numbers from the
Random array and count how often they fall witin a certain interval and save
these numbers within the proper interval. Amibroker is not suitable for that and
this is also not very usefull.
My point is that Random() has a "Flat"
distribution instead of a "Bell" shaped distribution (or at least this is
what I assume). I want to have a function that creates a "Bell" shaped
distribution but still lies between -1 and 1.
regards, Ed
/*
Random number
generator with a Gaussian distribution E.M.Pottasch, June 2005
Gaussian distribution with zero mean and a standard deviation of
one.
derived from: http://www.taygeta.com/random/gaussian.html
float x1, x2, w, y1, y2;
do { x1 = 2.0 *
ranf() - 1.0; x2 = 2.0 * ranf() - 1.0;
w = x1 * x1 + x2 * x2; } while ( w >= 1.0 );
w = sqrt( (-2.0 * ln( w ) ) / w ); y1 = x1 * w; y2 = x2 * w;
*/
function gauss_func() {
w = 1; while( w >= 1 ) {
x1 = 2.0 * LastValue(Random()) - 1; x2 = 2.0 * LastValue(Random()) - 1; w = x1 * x1 + x2 * x2;
}
w = sqrt( (-2 * log(w)) / w ); y1 = x1 * w;
//y2 = x2 *
w; return y1;
}
// fill array with ranom numbers hh = 0; for (i = 0; i
< BarCount; i++) {
hh[ i ] = gauss_func();
}
Plot(hh,"Gaussian distributed random numbers",colorWhite,1);
----- Original Message -----
Sent: Thursday, June 02, 2005 1:58
PM
Subject: Re: [amibroker] Random
numbers
Can this be plotted on AB so that we can see this
bell shaped gaussian curve?
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
|