Skip to content

Basic Example (Ishigami)

Start here if you want the smallest complete Sobol workflow. This page uses the Ishigami benchmark, then points you to the next examples in the recommended order.

Minimal Sobol run

python
import jaxgsa
from jaxgsa.benchmarks.ishigami import PROBLEM, evaluate

# Generate Saltelli samples (unique rows only)
sampling_result = jaxgsa.sobol.sample(
    PROBLEM,
    n_samples=4096,
    seed=42,
    calc_second_order=True,
)

# Evaluate your model on the unique rows
Y = evaluate(sampling_result.samples)

# Compute Sobol indices
result = jaxgsa.sobol.analyze(sampling_result, Y)

print("S1:", result.S1)
print("ST:", result.ST)
print("S2:", result.S2)

Expected output (A=7, B=0.1):

text
S1: [~0.31, ~0.44, ~0.00]
ST: [~0.56, ~0.44, ~0.24]

What the Ishigami result means

  • x2 has the largest first-order effect, so it explains the biggest share of variance by itself.
  • x1 has a moderate main effect but a much larger total effect, which signals interactions.
  • x3 has almost no main effect but still matters through interactions with x1.

Export the unique sample matrix

The core result stays a NumPy array. Export it with NumPy when another process needs a plain table:

python
import numpy as np

np.savetxt("samples.csv", sampling_result.samples, delimiter=",")

Practical caveats

  • Evaluate sampling_result.samples, not an expanded Saltelli matrix. jaxgsa reconstructs the expanded layout internally.
  • calc_second_order=False is a good speed and memory tradeoff when you only need S1 and ST. In that case result.S2 is None.
  • sample() may raise the internal base Sobol count until the deduplicated sample matrix contains at least n_samples unique rows.

Next examples

Follow these pages in order if you are learning the package:

If you want the theory behind the estimators before moving on, read Methods.

Released under the MIT License.