summaryrefslogtreecommitdiff
path: root/lib/rand.c
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2017-02-10 12:18:11 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2017-02-10 12:18:11 -0500
commit901b9f16494f37890be17ef4bb66e6efc6873340 (patch)
tree03e5f1769cbdb89eb1b4c45c16dc7d867184efaf /lib/rand.c
parent1e1fdfc2e3892667bccaf317a01defd8832041c7 (diff)
downloadfuse_networks-901b9f16494f37890be17ef4bb66e6efc6873340.tar.gz
fuse_networks-901b9f16494f37890be17ef4bb66e6efc6873340.tar.bz2
fuse_networks-901b9f16494f37890be17ef4bb66e6efc6873340.zip
changed code to rely on jst
Diffstat (limited to 'lib/rand.c')
-rw-r--r--lib/rand.c15
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;
+}