SensitivityAnalysis

Motivation and a worked example

Docstrings

SensitivityAnalysis.perturbation — Function
perturbation(label, lens, change; metadata, Δs, captured_errors)

Arguments

  • label: Label, used for lookup and printing.

  • lens: For changing an object via the Accessors.lens API.

  • change: A change calculator, eg ABSOLUTEor [RELATIVE](@ref), or a callable with the signature (x, Δ) -> new_x.

Keyword arguments

  • metadata: arbitrary metadata (eg for plot styles, etc). Passed through.

  • Δs: an AbstractVector or iterable of Δ values to be used by change above. When nothing, a default will be used, see perturbation_analysis.

  • captured_errors: a type (eg a Union{DomainError,ArgumentError}) that is silently captured and converted to nothing. These results will show up as NaN in moment sensitivities.

source
SensitivityAnalysis.perturbation_analysis — Function
perturbation_analysis(object, simulate; baseline_result, label, default_Δs)

A container for perturbation analysis.

Arguments

  • object: an opaque object that will be modified by perturbations

  • simulate: a callable on (changed) objects that returns a value moments can be calculated from. Should be thread safe. Can return nothing in case the simulation fails for whatever reason, in which case moments will use a NaN for the corresponding change.

Keyword arguments

  • baseline_result: a simulation result from object as is.

  • label: a global label for the whole analysis.

  • default_Δs: when a perturbation has no Δs specified, these will be used instead. Defaults to 11 values on ±0.1.

Usage

Once an analysis is created, you should push! perturbations into it. labels should be unique, as they can be used for lookup.

julia> using SensitivityAnalysis, Accessors

julia> anls = perturbation_analysis((a = 10.0, ), x -> (b = 2 * x.a, ))
perturbation results with default domain (-0.1, 0.1)

julia> push!(anls, perturbation("a", @optic(_.a), RELATIVE))
perturbation results with default domain (-0.1, 0.1)
  perturb a on default domain, relative change [capturing DomainError]

julia> moment_sensitivity(anls, "a", moment("b", x -> x.b, ABSOLUTE))
(label = "b (absolute change)", x = -0.1:0.02:0.1, y = [-2.0, -1.5999999999999979, -1.2000000000000028, -0.8000000000000007, -0.3999999999999986, 0.0, 0.3999999999999986, 0.8000000000000007, 1.2000000000000028, 1.6000000000000014, 2.0])

See also moment_sensitivity.

source
SensitivityAnalysis.moment — Function
moment(label, calculator, change; metadata)

Define a moment (a univariate statistic from simulation results).

Arguments

  • label: used for printing

  • calculator: a callable on simulation results

  • change: how changes should be interpreted, eg ABSOLUTEor [RELATIVE](@ref).

Keywoard arguments

  • metadata: passed through unchanged, can be used for plot styles, etc.
source
Missing docstring.

Missing docstring for moment_sensitivity. Check Documenter's build log for details.