summaryrefslogtreecommitdiff
path: root/lib/rand.c
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2017-02-10 12:19:46 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2017-02-10 12:19:46 -0500
commit0ef0c0ce1d904be2b4e1f4da62dc029d8572c983 (patch)
tree12978013d870186240c08d1fdd6a7ce8781bca93 /lib/rand.c
parent9a93a3b88a604672f557950e6c7f3fe815bcf163 (diff)
parent901b9f16494f37890be17ef4bb66e6efc6873340 (diff)
downloadfuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.tar.gz
fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.tar.bz2
fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.zip
Merge branch 'tmp'
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;
+}