> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ionworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Post-fit analysis

> Quantify a fit's uncertainty with iws.LinearConfidenceInterval and iws.SobolSensitivity as pipeline elements.

A fit gives you parameter values. Post-fit analysis tells you how much to trust
them: how tightly the data constrains each parameter, and which parameters the
model output actually responds to.

Both run as **pipeline elements**, alongside the fit rather than after it in
your own code, so the expensive part happens on the platform. For the concepts
behind variance-based sensitivity, see the
[Sensitivity Analysis Guide](/guide/data-fitting/sensitivity-analysis).

## The two elements

| Schema | Answers |
| - | - |
| `iws.LinearConfidenceInterval` | How tightly does the data constrain each fitted parameter? |
| `iws.SobolSensitivity` | Which parameters does the model output respond to, and which interact? |

Both take the same `objectives` and `parameters` as a `DataFit`. They accept
only a `PointEstimate` optimizer, because they analyse a fit rather than
performing one.

## Adding analysis to a pipeline

Place the analysis element after the fit it analyses. When its objectives and
parameters match the fit's, it picks up the fitted point automatically — you do
not restate the values:

```python theme={null}
import ionworks_schema as iws

pipeline = iws.Pipeline(
    {
        "fit": iws.DataFit(objectives=objectives, parameters=parameters),
        "intervals": iws.LinearConfidenceInterval(
            objectives=objectives,
            parameters=parameters,
        ),
        "sensitivity": iws.SobolSensitivity(
            objectives=objectives,
            parameters=parameters,
        ),
    }
)
```

## Options

Both elements work with their defaults; these adjust what they compute.

### `iws.LinearConfidenceInterval`

| Option | Default | Description |
| - | - | - |
| `confidence_level` | `0.95` | Central probability mass for each interval. Use `0.99` for wider intervals, `0.68` for one-sigma. |
| `use_parameter_bounds` | `True` | Clip intervals to the parameter bounds, so an interval never extends into values the fit could not have returned. |
| `variable_standard_deviations` | `None` | Per-variable measurement noise standard deviations, as a mapping. Supply these when you know your instrument's noise; otherwise it is estimated from the fit residuals. |
| `gauss_newton` | `True` | Use the Gauss-Newton Hessian approximation. |

```python theme={null}
intervals = iws.LinearConfidenceInterval(
    objectives=objectives,
    parameters=parameters,
    confidence_level=0.99,
)
```

### `iws.SobolSensitivity`

| Option | Default | Description |
| - | - | - |
| `n_samples` | `256` | Base sample count for the Sobol design. This is the cost knob — see the note below. |
| `calc_second_order` | `False` | Also compute second-order indices, which report how parameters interact in pairs rather than only their individual effect. Raises the evaluation count. |
| `use_log_transform` | `False` | Sample parameters in log space. Appropriate when a parameter ranges over orders of magnitude. |

```python theme={null}
sensitivity = iws.SobolSensitivity(
    objectives=objectives,
    parameters=parameters,
    n_samples=512,
    calc_second_order=True,
)
```

## Reading the results

Each element returns a typed result, reachable off the pipeline result rather
than by reading raw job metadata:

```python theme={null}
result = client.pipeline.result(pipeline_id)

intervals = result.element("intervals")     # iws.ConfidenceIntervalResult
sensitivity = result.element("sensitivity") # iws.SensitivityResult
```

<Note>
  Sobol sensitivity is a sampling method, so its cost grows with the number of
  parameters and with `n_samples` — the design uses
  `n_samples x (n_params + 2)` evaluations, rising to
  `n_samples x (2 x n_params + 2)` when `calc_second_order=True`. Start with a
  small parameter set and the default
  `n_samples`, and widen either once you know which parameters matter.
</Note>
