We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1faf29e commit 1c8bd5bCopy full SHA for 1c8bd5b
include/boost/random/inverse_gaussian_distribution.hpp
@@ -132,12 +132,12 @@ class inverse_gaussian_distribution
132
using std::sqrt;
133
#endif
134
RealType y = _alpha * chi_squared_distribution<RealType>(RealType(1.0))(urng);
135
- RealType cand_fac = result_type(1) + y - sqrt(result_type(2) * y + y * y);
+ RealType cand = _alpha + _alpha * (y - sqrt(y * (result_type(4) * _beta + y))) / (result_type(2) * _beta);
136
RealType u = uniform_01<RealType>()(urng);
137
- if (u <= 1 / (1 + cand_fac)) {
138
- return _alpha * cand_fac;
+ if (u < _alpha / (_alpha + cand)) {
+ return cand;
139
}
140
+ return _alpha * _alpha / cand;
141
142
143
/**
0 commit comments