summaryrefslogtreecommitdiff
path: root/src/rand.c
diff options
context:
space:
mode:
authorJaron <jaron@kent-dobias.com>2016-11-08 08:17:26 -0500
committerJaron <jaron@kent-dobias.com>2016-11-08 08:17:26 -0500
commit0ad947f800bcbe2c488d2d5cbcdb16c46e6d3857 (patch)
tree225b77daf1eefbf38457696172b5b8cd6095b155 /src/rand.c
parentbaae7b05b59917df132fde049a56357a09d45caa (diff)
downloadfuse_networks-0ad947f800bcbe2c488d2d5cbcdb16c46e6d3857.tar.gz
fuse_networks-0ad947f800bcbe2c488d2d5cbcdb16c46e6d3857.tar.bz2
fuse_networks-0ad947f800bcbe2c488d2d5cbcdb16c46e6d3857.zip
various changes, including adding central moments and changing the fuse thresholds to long doubles
Diffstat (limited to 'src/rand.c')
-rw-r--r--src/rand.c9
1 files changed, 6 insertions, 3 deletions
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;
}