summaryrefslogtreecommitdiff
path: root/lib/rand.c
blob: 8ba2b2b601d513655aa08dabf8b71ed03546fb57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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;
}