From 4a0d0aa69418e7be9ce05dd33e4c8501a987d22a Mon Sep 17 00:00:00 2001 From: johannes hanika Date: Mon, 3 Nov 2014 16:23:48 +0100 Subject: [PATCH] hslt: vmf.cpp numerical robustness --- src/libcore/vmf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/vmf.cpp b/src/libcore/vmf.cpp index 62622ff3..7d5a213b 100644 --- a/src/libcore/vmf.cpp +++ b/src/libcore/vmf.cpp @@ -31,7 +31,7 @@ Float VonMisesFisherDistr::eval(Float cosTheta) const { * m_kappa / (4 * M_PI * std::sinh(m_kappa)); #else /* Numerically stable version */ - return math::fastexp(m_kappa * (cosTheta - 1)) + return math::fastexp(m_kappa * std::min((Float)0, cosTheta - 1)) * m_kappa / (2 * M_PI * (1-math::fastexp(-2*m_kappa))); #endif }