diff options
author | Jaron <jaron@kent-dobias.com> | 2017-06-22 22:40:47 -0400 |
---|---|---|
committer | Jaron <jaron@kent-dobias.com> | 2017-06-22 22:40:47 -0400 |
commit | d59fc339a40a47405bfef8c1313e324adca70479 (patch) | |
tree | addf46044c3a1507bd4069797c6218c457b67e5f /lib/rand.c | |
parent | f4a50f1332ff323c42aa9664292910fd78933c15 (diff) | |
parent | 4764d5d407347d4dd5990411b243b3ec4bd75bff (diff) | |
download | fuse_networks-d59fc339a40a47405bfef8c1313e324adca70479.tar.gz fuse_networks-d59fc339a40a47405bfef8c1313e324adca70479.tar.bz2 fuse_networks-d59fc339a40a47405bfef8c1313e324adca70479.zip |
lots of changes for merge
Diffstat (limited to 'lib/rand.c')
-rw-r--r-- | lib/rand.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/rand.c b/lib/rand.c new file mode 100644 index 0000000..16aeba4 --- /dev/null +++ b/lib/rand.c @@ -0,0 +1,15 @@ + +#include "fracture.h" + +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 == 0.0) { + long double y = logl(gsl_rng_uniform_pos(r)) / beta; + x = expl(y); + } + + return x; +} |