From 1acd93a4f971d8258d0bd45d417e34cca42e0f64 Mon Sep 17 00:00:00 2001 From: syntheticdinosaur <94750216+syntheticdinosaur@users.noreply.github.com> Date: Sun, 29 May 2022 17:17:47 +0200 Subject: [PATCH] Add 'seed' argument to gaussian_random_field 'seed' for numpy.random.seed helps with reproducible results. --- gaussian_random_fields.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gaussian_random_fields.py b/gaussian_random_fields.py index 57def3d..240ecf1 100644 --- a/gaussian_random_fields.py +++ b/gaussian_random_fields.py @@ -47,7 +47,8 @@ def fftind(size): def gaussian_random_field(alpha = 3.0, size = 128, - flag_normalize = True): + flag_normalize = True, + seed = None): """ Returns a numpy array of shifted Fourier coordinates k_x k_y. Input args: @@ -70,7 +71,8 @@ def gaussian_random_field(alpha = 3.0, example = gaussian_random_field() plt.imshow(example) """ - + # Set random seed for reproducable results + numpy.random.seed(seed) # Defines momentum indices k_idx = fftind(size)