From 0ad947f800bcbe2c488d2d5cbcdb16c46e6d3857 Mon Sep 17 00:00:00 2001 From: Jaron Date: Tue, 8 Nov 2016 08:17:26 -0500 Subject: various changes, including adding central moments and changing the fuse thresholds to long doubles --- src/rand.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/rand.c') diff --git a/src/rand.c b/src/rand.c index 1a6a3d4..75722ac 100644 --- a/src/rand.c +++ b/src/rand.c @@ -9,12 +9,15 @@ unsigned long int rand_seed() { return seed; } -double rand_dist_pow(const gsl_rng *r, double beta) { - double x = 0; +long double rand_dist_pow(const gsl_rng *r, double beta) { + long double x = 0; // underflow means that for very small beta x is sometimes identically zero, // which causes problems - while ((x = exp(log(gsl_rng_uniform_pos(r)) / beta)) == 0.0); + while (x == 0.0) { + long double y = logl(gsl_rng_uniform_pos(r)) / beta; + x = expl(y); + } return x; } -- cgit v1.2.3-70-g09d2