diff options
author | Thomas White <taw@physics.org> | 2014-01-17 16:52:57 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-01-20 17:20:14 +0100 |
commit | 90ee3c269580104f2d16d28aeaa565063f6fc1f2 (patch) | |
tree | bd3c69f932648dc6fb01e4cce69bd27fb4831be2 /src/scaling-report.c | |
parent | 8e2f2f44f46c18f7bd621a2ef9a3d0aa813d76d9 (diff) |
RNG overhaul
Previously, we were using random(), which is really really bad.
Diffstat (limited to 'src/scaling-report.c')
-rw-r--r-- | src/scaling-report.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/scaling-report.c b/src/scaling-report.c index 89b2f3f2..85ed0ad2 100644 --- a/src/scaling-report.c +++ b/src/scaling-report.c @@ -196,6 +196,7 @@ static void partiality_graph(cairo_t *cr, Crystal **crystals, int n, double pcalcmin[nbins]; double pcalcmax[nbins]; int num_nondud; + gsl_rng *rng; show_text_simple(cr, "Observed partiality", -20.0, g_height/2.0, NULL, -M_PI_2, J_CENTER); @@ -223,6 +224,10 @@ static void partiality_graph(cairo_t *cr, Crystal **crystals, int n, num_nondud++; } + /* The reflections chosen for the graph will be the same every time + * (given the same sequence of input reflections, scalabilities etc) */ + rng = gsl_rng_alloc(gsl_rng_mt19937); + cairo_set_source_rgb(cr, 0.0, 0.7, 0.0); prob = 1.0 / num_nondud; for ( i=0; i<n; i++ ) { @@ -279,13 +284,15 @@ static void partiality_graph(cairo_t *cr, Crystal **crystals, int n, bin = nbins * pcalc; - if ( random_flat(1.0) < prob ) { + if ( random_flat(rng, 1.0) < prob ) { plot_point(cr, g_width, g_height, pcalc, pobs); } } } + gsl_rng_free(rng); + cairo_new_path(cr); cairo_rectangle(cr, 0.0, 0.0, g_width, g_height); cairo_clip(cr); |