[Top][All Lists]

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

[Bug-gsl] [bug #25039] gsl_ran_exponential range should be [0,inf]

From: Brian Gough
Subject: [Bug-gsl] [bug #25039] gsl_ran_exponential range should be [0,inf]
Date: Mon, 08 Dec 2008 19:26:49 +0000
User-agent: Emacs-w3m/1.4.4 w3m/0.5.2


                 Summary: gsl_ran_exponential range should be [0,inf]
                 Project: GNU Scientific Library
            Submitted by: bjg
            Submitted on: Mon 08 Dec 2008 07:26:47 PM GMT
                Category: Accuracy problem
                Severity: 2 - Minor
        Operating System: 
                  Status: Confirmed
             Assigned to: None
             Open/Closed: Open
                 Release: 1.12
         Discussion Lock: Any



From: "Adam Stinchcombe" <address@hidden>
To: address@hidden
Subject: [Bug-gsl] bug: 0 not possible result in gsl_ran_exponential
Date: Sat, 6 Dec 2008 19:04:35 -0500


Section 19.5 The Exponential Distribution
states that the distribution produces x >= 0, meaning that x=0 is a
possible result. The standard definition of the exponential
distribution also gives that x=0 is a possible value from the
distribution. The implementation in randist/exponential.c of gsl-1.11

gsl_ran_exponential (const gsl_rng * r, const double mu)
  double u = gsl_rng_uniform_pos (r);

  return -mu * log (u);

gsl_rng_uniform_pos returns a floating point number uniformly
distributed number on (0,1) , excluding both 0.0 and 1.0
). log maps (0,1) one-to-one and onto (-inf,0), excluding 0.0, which
means that the function above returns values on (0,inf),where inf is
the largest double. The point being that 0.0 is excluded as a possible
return value of the function.

I suggest the following implementation:

gsl_ran_exponential (const gsl_rng * r, const double mu)
  double u = gsl_rng_uniform (r);

  return -mu * log(1-u)

gsl_rng_uniform gives a value on [0,1) which is mapped to (0,1] by 1-u
and then to [0,inf) by log.

Since this distribution looks like the exponential everywhere except a
single point, I suspect that the statistics produced in the past were
not significantly incorrect. Please let me know if this is in fact a
bug or enlighten me as to my misunderstanding.

Adam Stinchcombe


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]