Change an internal table of constants for the poisson distribution from
authorMarshall Clow <mclow.lists@gmail.com>
Tue, 16 Jan 2018 14:54:36 +0000 (14:54 +0000)
committerMarshall Clow <mclow.lists@gmail.com>
Tue, 16 Jan 2018 14:54:36 +0000 (14:54 +0000)
type 'result_type' to 'double'. The only thing that we ever do with
these numbers is to promote them to 'double' and use them in a division.
For small result_types, the values were getting truncated, skewing the
results. Thanks to James Nagurne for the suggestion.

llvm-svn: 322556

libcxx/include/random

index 9073a52..89664a6 100644 (file)
@@ -4673,7 +4673,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
             double __py;
             if (__x < 10)
             {
-                const result_type __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
+                const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
                                              40320, 362880};
                 __px = -__pr.__mean_;
                 __py = _VSTD::pow(__pr.__mean_, (double)__x) / __fac[__x];