This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: Error in gsl_ran_gaussian_tail ?!
- To: Achim Gaedke <achim at zpr dot uni-koeln dot de>
- Subject: Re: Error in gsl_ran_gaussian_tail ?!
- From: Brian Gough <bjg at network-theory dot co dot uk>
- Date: Sat, 23 Jun 2001 12:34:46 +0100 (BST)
- Cc: gsl discussion list <gsl-discuss at sources dot redhat dot com>, ghmm-devel at zpr dot uni-koeln dot de
- References: <Pine.GSO.3.95.1010623004725.23066A-100000@Octopussy>
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;