From 4fc530a4e8a7408ccff7d2d2c43f4b311b2b4b38 Mon Sep 17 00:00:00 2001 From: Feda Curic Date: Fri, 8 Nov 2024 14:04:15 +0100 Subject: [PATCH] Do not sample from multivariate_normal in test Instead, add correlated PARAM5 ~ TruncatedNormal(3, 1, 1, 5) and PARAM6 ~ Uniform(0, 1) to design_input_background.xlsx. We don't want tests that call rng.multivariate_normal directly as that will change when we do latin hypercube sampling instead. Add check that lower bound must be less than upper bound in truncated normal --- .../sensitivities/design_distributions.py | 64 ++++++++------- .../data/config/design_input_background.xlsx | Bin 30186 -> 31005 bytes tests/sensitivities/test_create_design.py | 8 ++ .../test_design_distributions.py | 75 ++---------------- 4 files changed, 52 insertions(+), 95 deletions(-) diff --git a/src/fmu/tools/sensitivities/design_distributions.py b/src/fmu/tools/sensitivities/design_distributions.py index de1f1f7e..b9af4974 100644 --- a/src/fmu/tools/sensitivities/design_distributions.py +++ b/src/fmu/tools/sensitivities/design_distributions.py @@ -25,6 +25,13 @@ def _check_dist_params_normal(dist_params): elif float(dist_params[1]) < 0: status = False msg = "Stddev for normal distribution must be >= 0. " + elif len(dist_params) == 4 and float(dist_params[2]) >= float(dist_params[3]): + status = False + msg = ( + "For truncated normal distribution, " + "lower bound must be less than upper bound, " + f"but got [{dist_params[2]}, {dist_params[3]}]. " + ) else: status = True msg = "" @@ -141,7 +148,7 @@ def _check_dist_params_logunif(dist_params): def draw_values_normal(dist_parameters, numreals, rng, normalscoresamples=None): - """Draws values from normal distribution. + """Draws values from normal or truncated normal. Args: dist_parameters(list): [mean, std dev, min, max], min/max defining truncated normal @@ -152,39 +159,40 @@ def draw_values_normal(dist_parameters, numreals, rng, normalscoresamples=None): list of values """ status, msg = _check_dist_params_normal(dist_parameters) + if not status: raise ValueError(msg) - if len(dist_parameters) == 2: # normal - dist_mean = float(dist_parameters[0]) - dist_stddev = float(dist_parameters[1]) - if normalscoresamples is not None: - values = scipy.stats.norm.ppf( - scipy.stats.norm.cdf(normalscoresamples), - loc=dist_mean, - scale=dist_stddev, - ) - else: - distribution = scipy.stats.norm(dist_mean, dist_stddev) - values = distribution.rvs(size=numreals, random_state=rng) - else: # truncated normal or invalid - mean = float(dist_parameters[0]) - sigma = float(dist_parameters[1]) - clip1 = float(dist_parameters[2]) - clip2 = float(dist_parameters[3]) - low = (clip1 - mean) / sigma - high = (clip2 - mean) / sigma + + mean = float(dist_parameters[0]) + stddev = float(dist_parameters[1]) + + if len(dist_parameters) == 2: if normalscoresamples is not None: - values = scipy.stats.truncnorm.ppf( + return scipy.stats.norm.ppf( scipy.stats.norm.cdf(normalscoresamples), - low, - high, loc=mean, - scale=sigma, + scale=stddev, ) - else: - distribution = scipy.stats.truncnorm(low, high, loc=mean, scale=sigma) - values = distribution.rvs(size=numreals, random_state=rng) - return values + distribution = scipy.stats.norm(mean, stddev) + return distribution.rvs(size=numreals, random_state=rng) + + # Handle truncated normal case + clip1 = float(dist_parameters[2]) + clip2 = float(dist_parameters[3]) + low = (clip1 - mean) / stddev + high = (clip2 - mean) / stddev + + if normalscoresamples is not None: + return scipy.stats.truncnorm.ppf( + scipy.stats.norm.cdf(normalscoresamples), + low, + high, + loc=mean, + scale=stddev, + ) + + distribution = scipy.stats.truncnorm(low, high, loc=mean, scale=stddev) + return distribution.rvs(size=numreals, random_state=rng) def draw_values_lognormal(dist_parameters, numreals, rng, normalscoresamples=None): diff --git a/tests/sensitivities/data/config/design_input_background.xlsx b/tests/sensitivities/data/config/design_input_background.xlsx index 499f2c1016e3b9ad33566802d3a3c5e01698224a..61c8532bd8fec6feb11c83d897d9063afe66e251 100755 GIT binary patch delta 6913 zcmZvB1ymeO)9$jkI{}v95+txV!6mr61or^TVi6#)!Gp^Ji$jow;1&pO3Bd^(f(Ccj z1p=2h_uT*e{_otLGt=EuHGR6Pt7@vA-q}UVK0$k=qmGV20l)&_0000cfZrxNXAc?x z@TcYxKM=-QrZYir5~qWE1t8bXD2aslY9KnCR**P`L1bi+<}0ihtq!cCLvNdTPpomN z1S^_x_v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1K)jci&r^qCKJ<0xxXhoE>WY{He7CgBeRWX zWjB-c$F?VC%7CJL0G0HJ{C#jw*z5(-r`n@h)R64KNZ;lhZ5jp5&X1?y9;+sF?1faI zwBp%i|BhNiO`kng&eNsHN>0zs%@FZis|CAz0>zSbECWstlQBj@rb#C{%%&bDG?ynh zUleY%t?O%Ckbw>kSP=C8=)6FTml4hxu;9hc@~>_P0x{qC{oB|8N^e1y|Ern(+wTjQ zd2<21-ppVWDR9ex4tVQL2jKfKgWV|q!XGzK_Xhr?{R^di=m0+!O45G^2xkOpeH6gN zoWOS<4%UC=1klYR|Lr_5G}!=H06&;V^M=F= z^xl}7T7TypGW<$%z$nnKe)y8FMrws0;u~_vi{u)Z&DF)Bd<{X zhfkUn&>bibma+x@1j>OIpnz 0 for value in values) - with pytest.raises( ValueError, - match="Lognormal distribution must have 2 parameters, but had 3 parameters.", - ): - values = dists.draw_values_lognormal([10, 50, 100], 10, rng) - - with pytest.raises( - ValueError, match="Parameters for lognormal distribution must be numbers." - ): - values = dists.draw_values_lognormal(["a", 10], 10, rng) - - with pytest.raises( - ValueError, match="Lognormal distribution must have stddev >= 0." + match=( + "For truncated normal distribution, " + "lower bound must be less than upper bound, " + r"but got \[2, -1\]." + ), ): - values = dists.draw_values_lognormal([0, -1], 10, rng) + values = dists.draw_values_normal([0, 1, 2, -1], 10, rng) - -def test_draw_uniform_with_correlation(): - rng = np.random.RandomState() - correlation = 0.6 - n_samples = 1000 - - cov_matrix = [[1.0, correlation], [correlation, 1.0]] - normal_scores = rng.multivariate_normal([0, 0], cov_matrix, size=n_samples) - - values1 = dists.draw_values_uniform([0, 100], n_samples, rng, normal_scores[:, 0]) - values2 = dists.draw_values_uniform([10, 50], n_samples, rng, normal_scores[:, 1]) - - actual_correlation = np.corrcoef(values1, values2)[0, 1] - assert (actual_correlation - correlation) < 0.1 + values = dists.draw_values_normal([0, 10, -1, 2], 50, rng) + assert all(-1 <= value <= 2 for value in values) def test_draw_values_uniform():