From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian Gough To: Achim Gaedke Cc: gsl discussion list , ghmm-devel@zpr.uni-koeln.de Subject: Re: Error in gsl_ran_gaussian_tail ?! Date: Wed, 19 Dec 2001 13:20:00 -0000 Message-id: <15156.32470.166567.341324@debian> References: X-SW-Source: 2001/msg00239.html Achim Gaedke writes: > I've tried to generate random numbers distributed according to a > gaussian tail distribution... I've set the cutoff a to -4, 0 and > 4. For -4 and 0 I recieved the same result, the pictures are made > with gnuplot: This seems to be 2*gauss at positve values and is > correct for cutoff 0. cutoff 4 is correct. I just need negative > cutoffs (random money deposits e.g.). Thanks, the case a<0 was not implemented in randist/gausstail.c. It would make sense for it to always return the upper tail, which we can easily do by removing the 'fabs' from the first branch of the code there. I will do that. bjg|debian> cvs diff -u gausstail.c Index: gausstail.c =================================================================== RCS file: /cvs/gsl/gsl/randist/gausstail.c,v retrieving revision 1.4 diff -u -r1.4 gausstail.c --- gausstail.c 2001/04/23 09:38:28 1.4 +++ gausstail.c 2001/06/23 11:33:35 @@ -27,9 +27,8 @@ double gsl_ran_gaussian_tail (const gsl_rng * r, const double a, const double sigma) { - /* Returns a gaussian random variable larger than s - * This implementation does one-tailed deviates. - * FIXME: what to do about a < 0? + /* Returns a gaussian random variable larger than a + * This implementation does one-sided upper-tailed deviates. */ double s = a / sigma; @@ -43,7 +42,7 @@ do { - x = fabs (gsl_ran_gaussian (r, 1.0)); + x = gsl_ran_gaussian (r, 1.0); } while (x < s); return x * sigma;