This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Error in gsl_ran_gaussian_tail ?!


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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]