diff --git a/src/distributions.tpp b/src/distributions.tpp index b8ff81f..41bf79d 100644 --- a/src/distributions.tpp +++ b/src/distributions.tpp @@ -55,8 +55,13 @@ namespace reticula { template RealType residual_power_law_with_specified_mean::operator()( Generator& g) const { - std::uniform_real_distribution dist; - return _x_min*std::pow((1.0 - dist(g)), 1.0/(1.0 - _exponent)); + auto u = std::uniform_real_distribution{}(g); + if (u*_mean < _x_min) + return u*_mean; + + return _x_min * std::pow( + (1.0 - dist(g)) * (_exponent - 1.0), + 1.0 / (_exponent - 2.0)); } template @@ -74,7 +79,7 @@ namespace reticula { return _mean; } - // hawkes_univariate_exponential + // Hawkes_univariate_exponential template hawkes_univariate_exponential::hawkes_univariate_exponential( RealType mu, RealType alpha, RealType theta, RealType phi) :