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
x2has the largest first-order effect, so it explains the biggest share of variance by itself.x1has a moderate main effect but a much larger total effect, which signals interactions.x3has almost no main effect but still matters through interactions withx1.
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.jaxgsareconstructs the expanded layout internally. calc_second_order=Falseis a good speed and memory tradeoff when you only needS1andST. In that caseresult.S2isNone.sample()may raise the internal base Sobol count until the deduplicated sample matrix contains at leastn_samplesunique rows.
Next examples
Follow these pages in order if you are learning the package:
- Non-Uniform Inputs for mixed uniform, Gaussian, and truncated Gaussian Sobol marginals.
- Save and Reload Samples for persisting
SobolSamplesplus Saltelli reconstruction metadata. - Bootstrap Confidence Intervals for uncertainty bounds and confidence-interval shapes.
- Multi-Output & Time-Series for fully runnable
(N, T, K)outputs with named outputs. - xarray Labeled Output for turning results into labeled datasets and selecting by parameter, output, and time.
- RS-HDMR Example for the surrogate-based workflow that works with arbitrary
(X, Y)pairs. - Advanced Workflow for one end-to-end custom model that combines Sobol, HDMR, emulator prediction, and
to_dataset().
If you want the theory behind the estimators before moving on, read Methods.