diff options
author | tlatorre <tlatorre@uchicago.edu> | 2019-11-18 11:22:24 -0600 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2019-11-18 11:22:24 -0600 |
commit | bf6b7fbdab8e3d3f025954fdb559310c452271e0 (patch) | |
tree | 5851abd1be2ee2022ec8dfdae06b758176e4ea17 /src/random.c | |
parent | bcf57e127f17b715cdf3ce39f44a45f82c2473fd (diff) | |
download | sddm-bf6b7fbdab8e3d3f025954fdb559310c452271e0.tar.gz sddm-bf6b7fbdab8e3d3f025954fdb559310c452271e0.tar.bz2 sddm-bf6b7fbdab8e3d3f025954fdb559310c452271e0.zip |
add a new test for the quad fitter
This commit adds a new test to test the quad fitter when the t0 quantile
argument is less than 1.
Diffstat (limited to 'src/random.c')
-rw-r--r-- | src/random.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/random.c b/src/random.c index 482e102..8f005eb 100644 --- a/src/random.c +++ b/src/random.c @@ -18,13 +18,14 @@ #include <math.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> +#include "vector.h" static gsl_rng *r; +/* Generates a random number from a normal distribution using the Box-Muller + * transform. */ double randn(void) { - /* Generates a random number from a normal distribution using the - * Box-Muller transform. */ double u1, u2; u1 = genrand_real1(); @@ -33,9 +34,23 @@ double randn(void) return sqrt(-2*log(u1))*cos(2*M_PI*u2); } +/* Generates a random point in the unit sphere. */ +void rand_ball(double *pos, double radius) +{ + pos[0] = (genrand_real2()*2 - 1)*radius; + pos[1] = (genrand_real2()*2 - 1)*radius; + pos[2] = (genrand_real2()*2 - 1)*radius; + + while (NORM(pos) >= radius) { + pos[0] = (genrand_real2()*2 - 1)*radius; + pos[1] = (genrand_real2()*2 - 1)*radius; + pos[2] = (genrand_real2()*2 - 1)*radius; + } +} + +/* Generates a random point on the unit sphere. */ void rand_sphere(double *dir) { - /* Generates a random point on the unit sphere. */ double u, v, theta, phi; u = genrand_real1(); |