bugGNU Scientific Library - Bugs: bug #43326, Bug in gsl_ran_poisson_pdf() for...

 
 

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

bug #43326: Bug in gsl_ran_poisson_pdf() for mu = 0.0

Submitter:  Patrick Alken <psa>
Submitted:  Mon 29 Sep 2014 05:42:30 PM UTC
   
 
Category:  Runtime error Severity:  3 - Normal
Operating System:  Status:  None
Assigned to:  None Open/Closed:  Open
Release: 

Mon 03 Feb 2025 04:31:29 PM UTC, comment #2: 

First order patch in this case means:
1- test cases not provided, although something like the sample code below proves the result
2- solution does not work in conjunction with histograms, as this will yield a xmin larger than xmax error; however, given that the case is degenerate, more than likely other error messages will be presented too.

#include <stdio.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>

int
main (void)
{
  for (int k = 3; k >= 0; k--)
    for (double mu_ = 1; mu_ >= 0; mu_ -= 0.1)
      printf("%d\t%.1f\t%f\n", k, mu_, gsl_ran_poisson_pdf(k, mu_));

  return 0;
}

Fermé le Lundi <fermelelundi>
Sun 02 Feb 2025 10:33:31 PM UTC, comment #1: 

A first-order patch for this issue. Affects file randist/poisson.c only. Test cases not included.

(file #56846)

Fermé le Lundi <fermelelundi>
Mon 29 Sep 2014 05:42:30 PM UTC, original submission:  

From kai =dot= wassmuss =at= gmx =dot= de

Dear GSL maintainers,

gsl_ran_poisson_pdf() uses a clever method to evaluate the poisson pmf
p(n) = (mu^n / n!) exp(-mu)
without evaluating the factorial directly.
To do so, it evaluates log(mu). In the special case mu = 0 this returns
-nan and so gsl_ran_poisson_pdf() returns -nan.

mu = 0 corresponds to a poisson process with rate 0 and the return value
of gsl_ran_poisson_pdf(k, mu) should consequently be 1.0 for k=0 and 0.0
for k>0.

This bug is similar to
https://savannah.gnu.org/bugs/?func=detailitem&item_id=36328, which was
accepted for octave.

Best regards,
Kai

Patrick Alken <psa>
Group administrator

 

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

Attached Files
file #56846:  bug43326.diff added by fermelelundi (610B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by fermelelundi (Updated the item)
  • -email is unavailable- added by psa (Submitted the item)
  •  

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-02-02 fermelelundi Attached File- Added bug43326.diff, #56846

    Back to the top

    Powered by Savane 3.14-7003.
    Corresponding source code