diff options
author | Thomas White <taw@physics.org> | 2011-07-14 15:10:37 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:33 +0100 |
commit | c6af54b9a326119ab43a06fd209d2009df64f07e (patch) | |
tree | 8115216e90662a06cc802267b53fb9e5a6117085 /src/utils.c | |
parent | 812bce99717e18289b02f515180c8d9ae8ca1827 (diff) |
partial_sim: Use flat noise in cell parameters
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c index 4b4bfb51..6b29627f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -121,6 +121,19 @@ void progress_bar(int val, int total, const char *text) } +double random_flat(double max) +{ + return max * (double)random()/RAND_MAX; +} + + +double flat_noise(double expected, double width) +{ + double noise = random_flat(2.0*width); + return expected+noise-width; +} + + double gaussian_noise(double expected, double stddev) { double x1, x2, noise; |