Parameter Importance
When you have a model that takes a parameter
vector and returns a scalar, “parameter importance” is the question
which matters most for the output. Numra answers this with
compute_sensitivities,
a one-shot local sensitivity routine built on central finite differences.
Computing sensitivities
Section titled “Computing sensitivities”The basic form takes a closure, a nominal parameter vector, optional parameter names, and an optional finite-difference step size:
use numra::compute_sensitivities;
// A model: output = a^2 · sin(b) + clet f = |p: &[f64]| p[0] * p[0] * p[1].sin() + p[2];let params = [3.0, 1.5, 10.0];let names = ["a", "b", "c"];
let result = compute_sensitivities(f, ¶ms, &names, None);
println!("Output: {:.4}", result.output);for s in &result.sensitivities { println!( "{}: coefficient = {:.4}, normalized = {:.4}", s.name, s.coefficient, s.normalized, );}Each parameter contributes one row to result.sensitivities.
Sensitivity metrics
Section titled “Sensitivity metrics”Each parameter gets two metrics:
| Metric | Formula | Interpretation |
|---|---|---|
| Coefficient | Absolute rate of change — has units. | |
| Normalized | Dimensionless elasticity. A value of means a 1% change in produces approximately a 0.5% change in the output. |
Use the coefficient when you care about the physical scale of sensitivity (e.g. “how many degrees Celsius does the output shift per unit change in this rate constant?”). Use the normalized sensitivity when you want to rank parameters whose values span very different magnitudes — say, a rate constant of alongside a temperature of .
Finding the most important parameter
Section titled “Finding the most important parameter”A common follow-up is “which is the most influential parameter?”:
let most = result.most_sensitive().unwrap();println!( "Most influential: {} (normalized = {:.4})", most.name, most.normalized,);most_sensitive ranks by the absolute value of normalized. For
problems where parameters share a common physical unit, you may prefer
to rank by coefficient.abs() instead — iterate manually and sort.
Uncertainty propagation from sensitivities
Section titled “Uncertainty propagation from sensitivities”If you also know the variances of the input parameters, the local linearisation lets you estimate the output variance directly:
assuming the parameters are independent and the function is well approximated as linear in the parameter range of interest. Numra exposes this as a one-line helper:
let param_variances = [0.1, 0.05, 1.0]; // Var(a), Var(b), Var(c)let output_variance = result.propagate_uncertainty(¶m_variances);println!("Predicted output std: {:.4}", output_variance.sqrt());For correlated parameters, larger uncertainties, or strongly nonlinear
, this first-order estimate can be very wrong — fall back to
Monte Carlo or full uncertainty propagation via
Uncertain<S>.
Finite-difference step size
Section titled “Finite-difference step size”The default step size is , a relative step that adapts to each parameter’s magnitude. Override the step size when needed:
let result = compute_sensitivities(f, ¶ms, &names, Some(1e-5));| Direction | Effect |
|---|---|
| Smaller | Lower truncation error; more susceptible to floating-point cancellation. |
| Larger | More cancellation-resistant; truncation error grows quadratically (central FD). |
The default is a good compromise for most well-conditioned problems and gives roughly correct digits when the function is smooth and not pathologically scaled.
When to use this vs forward sensitivity
Section titled “When to use this vs forward sensitivity”compute_sensitivities is the right tool when:
- The model is a scalar function of parameters, not a trajectory.
- You want a quick local picture at one nominal parameter point.
- The function is reasonably smooth and you can afford evaluations (central FD plus baseline).
If your model is an ODE/DAE and you want at every output time along the trajectory, you want the forward sensitivity primitive on the Sensitivity Analysis page instead. The augmented-system approach there integrates state and sensitivity together — one solver call, single source of truth on tolerances and step control, and analytical Jacobians available where they matter.