bugGNU Scientific Library - Bugs: bug #25039, gsl_ran_exponential range should...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #25039: gsl_ran_exponential range should be [0,inf]

Submitter:  -Deleted Account- <bjg>
Submitted:  Mon 08 Dec 2008 07:26:47 PM UTC
   
 
Category:  Accuracy problem Severity:  2 - Minor
Operating System:  Status:  Fixed
Assigned to:  None Open/Closed:  Closed
Release:  1.12

Fri 10 Jul 2009 03:37:11 PM UTC, comment #1: 

fixed by  7c5def0a90ff1d3d56e723c4b827dd2ffdcbab49

-Deleted Account- <bjg>
Mon 08 Dec 2008 07:26:47 PM UTC, original submission:  

From: "Adam Stinchcombe" <ars522@cims.nyu.edu>
To: -email is unavailable-
Subject: [Bug-gsl] bug: 0 not possible result in gsl_ran_exponential
Date: Sat, 6 Dec 2008 19:04:35 -0500

Hello,

Section 19.5 The Exponential Distribution
(http://www.gnu.org/software/gsl/manual/gsl-ref.html#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
is

double
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
(http://www.gnu.org/software/gsl/manual/gsl-ref.html#index-gsl_005frng_005funiform_005fpos-1486
). 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:

double
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.

Cheers,
Adam Stinchcombe


-Deleted Account- <bjg>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bjg
  •  

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-07-10 bjg StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2008-12-08 bjg Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code