This page will look better in a graphical browser that supports web standards, but is accessible to any browser or internet device.

-->

Introduction to JSim Sensitivity Analysis

Introduction

This document describes model sensitivity analysis under JSim. Sensitivity analysis is the process of determining how small pertubations of model inputs affect model outputs. Suppose a model has an input parameter p and an output f(t). The derivative df/dp (f:p in JSim syntax) quantifies how f changes with small perturbations of p.

Prerequisites:

A video designed to accompany this document may be found here .

Analytic Approach vs. Finite Differences

Numerical calculation of f:p can be done analytically or via finite differences. Since JSim models are normally specified analytically in MML, calculation of f:p can be simple in some circumstances. For instance if:

f=p*sin(t)

then, by simple calculus:

f:p=sin(t)

Unfortunately, two problems may arise with the analytic approach. First, not all JSim models are completely analytic. Specifically, JSim cannot symbolically differentiate variables that are calculated from JSim function generators or external functions and procedures. Second, if a model is very large, the overhead for calculating analytic derivatives may be large, making analytic calculation inefficient.

Alternatively, we may use finite differences to calculate f:p. This involves making two model runs at p=p0 and p=p0+delta (for small delta) and estimating:

f:p=(f(p0+delta)-f(p0))/delta  

The advantages of this approach are that it can work for any JSim model (not just a differentiable one) and that computation time is bounded and predictable (twice that of a normal model run). The disadvantages are that the user must now configure two model runs (instead of one) and wait twice as long for results.

At present, JSim only supports sensitivity analysis using finite differences. Future JSim releases will, hopefully, also support the analytic method where appropriate.

A First Example

Consider the following model, which generates exponential decay and decaying sine & cosine waves:

// Sensitivity analysis tutorial model
math sens1 { 
	realDomain t;
	t.min=0; t.max=4*PI; t.delta=0.1;
	real amp = 1;
	real phase = 0;
	real decay = 1;

	real u(t) = amp*exp(-decay*t);
	real v(t) = u * sin(t+phase);	
	real w(t) = v * cos(t+phase);	
}
(Java plugin required)

Either download the model and load it into your local JSim application or run it in the JSim applet as you prefer. Then play with the model a bit until you understand its behaviour.

Now let's analyze the model's sensitivity to the decay parameter. Open JSim's "Sensitivity" subtab within the model tab. You will see a 3 column table. In the "Parameter" column type in "decay" (or select decay from the list that appears when you push the associated arrow button). The box should blacken (indicating that "decay" is acceptable here), a check mark should appear in the OK column, and decay's current value will be shown in the "Value" column. If you've changed decay's value while you were playing around above, change it back to 1 (the default value). The "Delta" column should show the default value of 0.01. This indicates that the two values decay will assume in the finite differences method will be 1 and 1.01 (delta is always added to the current value). Now press the "Run" button at the top of the Sensitivity subtab. JSim will run the model twice, once for decay=1, once for decay=1.01.

To examine results, go to a plot page. You may now examine variables such as u:decay, v:decay and w:decay. You may use these variables in expressions such as:

u:decay/amp
10*u:decay
(v*w):decay

If, at this point, you try plotting e.g. v:phase you will notice that the expression is accepted by JSim (the box blackens and the item appears in the legend) but no data is graphed. This is because JSim cannot calculate this data without doing a sensitivity analysis on phase. To remedy this, go back to the "Sensitivity" subtab, put "phase" into the 2nd row Parameter box, and rerun the sensitivity. Now JSim will perform 3 model runs: an unperturbed run, a run with decay perturbed, and a run with phase perturbed. Once the runs complete, data for v:phase will appear in the plot page.

Note that a normal (single) model run, which happens when you press the "Run" on a model's "Run Time" tab does not generate any sensitivity data. Therefore, sensitivity derivatives will show no data on plot pages after normal model runs. We realize that, in some circumstances, this could be confusing and are looking into ways to alert new users to what's going on without hampering the work of expert users. Thank you for your patience in this regard.

[This page was last modified 03Mar08, 3:11 pm.]

Model development and archiving support at physiome.org provided by the following grants: NIH/NHLBI T15 HL88516-01 Modeling for Heart, Lung and Blood: From Cell to Organ, 4/1/07-3/31/11; NSF BES-0506477 Adaptive Multi-Scale Model Simulation, 8/15/05-7/31/08; NIH/NHLBI R01 HL073598 Core 3: 3D Imaging and Computer Modeling of the Respiratory Tract, 9/1/04-8/31/09; as well as prior support from NIH/NCRR P41 RR01243 Simulation Resource in Circulatory Mass Transport and Exchange, 12/1/1980-11/30/01 and NIH/NIBIB R01 EB001973 JSim: A Simulation Analysis Platform, 3/1/02-2/28/07.