From 48b4cad4cb20690dff4fb43fd99296e5de7343e5 Mon Sep 17 00:00:00 2001 From: Gary Wolfman Date: Thu, 23 Apr 2026 21:46:04 -0400 Subject: [PATCH] Fix Poisson PMF denominator for integer observations Replace factorial(k) with tgamma(k+1) in poisson_pdf to avoid small-k inaccuracies from the Stirling-based approximation. Co-Authored-By: Oz --- src/PDF.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PDF.cpp b/src/PDF.cpp index af88cf45..9f144508 100644 --- a/src/PDF.cpp +++ b/src/PDF.cpp @@ -181,7 +181,7 @@ namespace StochHMM{ std::cerr << "Poisson PMF: Incorrect parameters\n"; exit(2); } - return (pow(lambda,(double)k)* exp(-1*lambda))/factorial(k); + return (pow(lambda,(double)k)* exp(-1*lambda))/tgamma((double)k+1.0); }