[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Random numbers



PureBytes Links

Trading Reference Links

thanks,
 
will have a look,
 
rgds, Ed
 
----- Original Message -----
From: bilbod
Sent: Thursday, June 02, 2005 4:27 PM
Subject: Re: [amibroker] Random numbers

Here is a link with approximations to convert a uniform probability distribution to Gaussian. I think what you want is a zero mean and a standard deviation small enough to the probability you desire for + or - 1. By lowering the SD, the tails will go to 0 faster.

Bill

ed nl wrote:
hi,
 
the random() function generates numbers between 0 and 1, distributed "linearly" (not sure this is the proper term  -> statistics was a while back .....). Meaning that if you run Lastvalue(random()) a million times we would about get the same hits with 0.9 as with 0.3.
 
(0.5 - Random()) * 2  gives you a function with numbers between -1 and 1  with a "linear" distribution.
 
What I want is to generate random numbers between -1 and 1 which do not have a "linear" distribution. They should have some kind of Gaussian distribution where chances a number generated near 0 is greater than a number generated neat -1 or 1. 
 
I made this Gauss function (see below) but this generates numbers with a standard deviation of 1 but does not have a high or low number restriction.  So I want the numbers to fluctuate randomly between -1 and 1 but still have some form of Gauss function in them so that a hit at 1 occurs less frequent than at 0.3.
 
thanks,
 
rgds, Ed
 
 
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;

}



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






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





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