diff options
| author | warren <warren.weckesser@gmail.com> | 2021-09-23 07:01:41 -0400 |
|---|---|---|
| committer | warren <warren.weckesser@gmail.com> | 2021-09-23 07:01:41 -0400 |
| commit | d1ed2c2b1eecac38cc31a9cc2ad15c86fd520137 (patch) | |
| tree | c6e1ba9dd2a30bf7d142a7437a891f18388585a1 /numpy/random/src | |
| parent | c64c7cc0b36256581c29311675af3f50b0f2df3e (diff) | |
| download | numpy-d1ed2c2b1eecac38cc31a9cc2ad15c86fd520137.tar.gz | |
MAINT: random: Use expm1 where appropriate.
Diffstat (limited to 'numpy/random/src')
| -rw-r--r-- | numpy/random/src/distributions/distributions.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/random/src/distributions/distributions.c b/numpy/random/src/distributions/distributions.c index 9bdfa9bea..adf4db4a7 100644 --- a/numpy/random/src/distributions/distributions.c +++ b/numpy/random/src/distributions/distributions.c @@ -452,7 +452,7 @@ double random_standard_cauchy(bitgen_t *bitgen_state) { } double random_pareto(bitgen_t *bitgen_state, double a) { - return exp(random_standard_exponential(bitgen_state) / a) - 1; + return expm1(random_standard_exponential(bitgen_state) / a); } double random_weibull(bitgen_t *bitgen_state, double a) { @@ -463,7 +463,7 @@ double random_weibull(bitgen_t *bitgen_state, double a) { } double random_power(bitgen_t *bitgen_state, double a) { - return pow(1 - exp(-random_standard_exponential(bitgen_state)), 1. / a); + return pow(-expm1(-random_standard_exponential(bitgen_state)), 1. / a); } double random_laplace(bitgen_t *bitgen_state, double loc, double scale) { @@ -918,7 +918,7 @@ int64_t random_logseries(bitgen_t *bitgen_state, double p) { return 1; } U = next_double(bitgen_state); - q = 1.0 - exp(r * U); + q = -expm1(r * U); if (V <= q * q) { result = (int64_t)floor(1 + log(V) / log(q)); if ((result < 1) || (V == 0.0)) { |
