Skip to content

dgsm.analyze: dgsm_conf is the bootstrap interval of vi, not of dgsm #698

Closed

Description

@rmz-oz

dgsm.analyze returns a dgsm_conf that is not in the same units as dgsm. In calc_dgsm the bootstrap resamples only vi:

dgsm = vi * (bounds[1] - bounds[0]) ** 2 / (D * np.pi**2)
...
s[i] = calc_vi_mean(base[r_i], perturbed[r_i], x_delta[r_i])
...
return dgsm, norm.ppf(0.5 + conf_level / 2.0) * s.std(ddof=1)

so the returned interval is the interval of vi, without the (ub - lb)**2 / (D * pi**2) factor. An easy way to see it is that dgsm does not change when the output is multiplied by a constant, but dgsm_conf grows with the square of that constant.

import numpy as np
from SALib.sample import finite_diff
from SALib.analyze import dgsm
from SALib.test_functions import Ishigami

problem = {"num_vars": 3, "names": ["x1", "x2", "x3"], "bounds": [[-np.pi, np.pi]] * 3}
X = finite_diff.sample(problem, 1000, seed=1)
Y = Ishigami.evaluate(X)

for scale in (1, 10):
    Si = dgsm.analyze(problem, X, scale * Y, seed=1)
    print(scale, Si["dgsm"].round(3), Si["dgsm_conf"].round(3))

Output:

1 [2.243 7.071 3.292] [1.035 0.981 1.534]
10 [2.243 7.071 3.292] [103.461  98.082 153.4  ]

Expected: dgsm_conf stays the same when Y is scaled, like dgsm. For reference, bootstrapping the dgsm value itself (recomputing vi and np.var(base) on each resample) gives half-widths of roughly [0.35 0.8 0.3] for the unscaled Ishigami case. For a term that is linear in its input, vi is the same in every resample, so dgsm_conf is 0 even though dgsm still varies through D.

A fix would be to compute vi * (ub - lb)**2 / (np.var(base[r_i]) * np.pi**2) inside the bootstrap loop, or at least scale the vi interval by the same factor as dgsm.

Versions: SALib 1.6.0 from PyPI and main at c8b2be5, numpy 2.5.3, scipy 1.18.1, Python 3.13, macOS arm64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions