Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Binder

In this chapter we discuss concepts for uncertainty quantification for simulation outcomes.

Objectives:

  • What is uncertainty and why is it important to quantify it?

  • How can we quantify and communicate uncertainty?

Loading...
Loading...
Loading...
Loading...
Loading...

Uncertainty (Definition)

Uncertainty refers to epistemic situations involving imperfect or unknown information and arises in partially observable or stochastic or complex or dynamic environments (as well as due to ignorance, indolence, or both Thrun & Norvig (2012)). For modelling and simulation, we distinguish two major sources for uncertainty (see also Figure 1):

Since we can only model what we can perceive and measure in reality, our image of the real system is generally incomplete. This can have many causes and consequences: Maybe our perception of the causal relationships in reality may be flawed, or our measurements from the real system may be unwittingly inaccurate. Maybe, also the system boundaries that one is inevitably forced to set in order to make sense of the system may also be to blame for the fact that it is not possible to capture the system’s behaviour perfectly. We will furthermore summarise this hidden source of uncertainty as intrinsic or Aleatoric uncertainty Der Kiureghian & Ditlevsen (2009).

The second source for uncertainty is the modelling process itself, in which the modeller has to make simplifications in order to describe the perceived system in a conceptual and furthermore implemented model. This for example also includes known inaccuracies and limitations of available data used for parametrisation. We will call this sources of uncertainty as model/data or Epistemic uncertainty Der Kiureghian & Ditlevsen (2009). The main difference to the first source is that, the modeller not only recognises that there is uncertainty regarding a certain system component, but also knows exactly why, since the modeller has consciously decided for the abstraction and simplification steps responsible.

Visualisation of different sources for uncertainty.

Figure 1:Visualisation of different sources for uncertainty.

In order to advise a decision-maker effectively, it is important to communicate the implications of uncertainty – regardless of its cause. Only then will they have a complete picture of the situation and be able to plan accordingly.

Case-Study: Weather Forecast

Let us take the weather forecast as a thought experiment to illustrate the point.

  • Aleatoric uncertainty: Even though we have been observing the processes associated with the weather for many centuries, there are still many things we do not yet understand. While the understanding of the atmosphere as a multi-scale system and of the role of scale interactions in determining weather and climate variability has developed strongly (see, Slingo & Palmer (2011)) during the last centuries there is still no (and will likely never be) “Grand Unified Theory” which perfectly describes all components of the system.

  • Epistemic uncertainty:

    • Model specification: Simplifications when specifying the differential equations and parameters. Leave out micro-effects or negligibly small factors.

    • Numerics: Grid used for numerical computations

    • System boundaries: Only a part of the world is depicted at once. We do not regard e.g. anything higher than ....

    • Parameters: Parameter values come from inaccurate measurements

    • Input: Initial conditions not perfectly known (we cannot measure the weather anywhere at once)

Uncertainty & Stochasticity

Clearly, stochasticity is the key to incorporate uncertainty in simulation results. There are, in principle, three concepts for integrating stochasticity (see Figure 2): (a) Inherently stochastic models, e.g. discrete event models or agent-based models, integrate stochasticity by default. However, there is not guarantee that this covers all uncertainty involved and one should also consider adding additional stochasticity at other points. (b) Input and (c) parameter uncertainty can be incorporated by stochastically varying input (e.g. initial conditions) and parameter values. Clearly (a), (b) and (c) can be combined as well.

Concepts for considering stochasticity in simulation models.

Figure 2:Concepts for considering stochasticity in simulation models.

Anyhow, in all three cases we find, that the model’s states and in particular outputs, are no longer deterministic (e.g. a scalar, a vector or a function of time) but are instead a random variable (e.g. scalar-valued, vector-valued or stochastic process).

Quantification of Uncertainty

As already mentioned, quantifying the uncertainty associated with the model is crucial to ensuring that the results can be used as effectively as possible as a basis for decision-making.

Case-Study: Manufacturing - Analytic

We illustrate this by a very simple case study: Let us assume that a company manufactures a certain product and wishes to sell it. During production, there is a probability 0<p≪10<p\ll 1 that a fault will occur, rendering the product unsaleable. It is clear that the firm’s expected revenue RR from the production of NN products is

E(R)=N(1−p)c,\mathbb{E}(R)=N(1-p)c,

where cc is the selling price of a product, assuming that all viable products will be sold. However, this information does not incorporate the corresponding uncertainty and is therefore insufficient for planning.

Since the sum of Bernoulli distributed (i.e. either zero or one) random variables is known to follow a Binomial distribution, we may compute the individual probabilities

k∈{0,…,N}:P(R=ck)=c(Nk)(1−p)kpN−kk\in \{0,\dots,N\}: P(R=ck)=c\left(\begin{array}{c}N\\k\end{array}\right)(1-p)^kp^{N-k}

and use this information to specify regions of confidence. For example, defining

kq:=max⁡k∈{0,…,N}:∑k=0kqP(R=ck)<1−qk_{q}:=\max_{k\in \{0,\dots,N\}}:\sum_{k=0}^{k_{q}}P(R=ck)<1-q

we find that wth 100q%100q\% certainty, the manufacturing of NN products will yield a revenue of at least ckqck_{q}.

With this additional information, the decision-maker is now better placed to plan, e.g. future expenditures. How they choose to do this is now down to their willingness to take risks.

The situation is implemented below.

expected revenue 176.4
minimum revenue (90% certainty): 171
minimum revenue (99% certainty): 162

Case-Study: Manufacturing - Monte Carlo

The prior analysis was based on the important property that the distribution of the revenue, i.e. the Binomial distribution, was analytically known and understood. However, in the general case this is not possible and one needs to rely on numerical approximations.

Clearly, the Monte Carlo Method / Simulation, as introduced in chapter Monte Carlo Simulation is the key to this. While it is originally designed to estimate the unknown mean value of the distribution (by the sample mean), it does, per se, not limit itself to any specific statistic and can be used to estimate arbitrary moments, confidence intervals or entire distributions. Below, the revenue problem is solved using a Monte Carlo approach.

expected revenue 176.4081
minimum revenue (90% certainty): 171.0
minimum revenue (99% certainty): 162.0

Case-Study: Predator-Prey model

To study uncertainty quantification we will use the predator-prey model from Chapter Simulation Circle as a case study whilst disregarding the modelling of the intervention. The model is defined as a system of two coupled differential equations

dxdt(t)=x(t)(α1−β1)−x(t)y(t)γ,\frac{dx}{dt}(t)=x(t)(\alpha_1-\beta_1)-x(t)y(t)\gamma,

dydt(t)=y(t)(α2−β2)+x(t)y(t)γδ.\frac{dy}{dt}(t)=y(t)(\alpha_2-\beta_2)+x(t)y(t)\gamma\delta.

and has six parameters α1,β1,α2,β2,γ,δ\alpha_1,\beta_1,\alpha_2,\beta_2,\gamma,\delta. The two cuves xx and yy descibe the population size of a prea and predator species and α1/2\alpha_{1/2} and β1/2\beta_{1/2} are the corresponding reproduction and death rates. In the model they actually only enter as their respective differences whereas the model leads to traditional predator-prey behaviour when α1>β1\alpha_1>\beta_1 and α2<β2\alpha_2<\beta_2. The parameters γ\gamma and δ\delta influence the interaction between the species in terms of one hunting and eating the other.

For the case study we fix

α1=0.2,β1=0.1,α2=0.1,β2=0.3, and δ=1.\alpha_1=0.2,\beta_1=0.1,\alpha_2=0.1,\beta_2=0.3,\text{ and }\delta=1.

To incorporate uncertainty we further specify, that neither initial values nor interaction terms between the two species are perfectly known. We define

γ∼N(0.3,0.02),x(0)=x0∼N(0.5,0.02), and y(0)=y0∼N(0.1,0.01)\gamma\sim \mathcal{N}(0.3,0.02),x(0)=x_0\sim\mathcal{N}(0.5,0.02),\text{ and } y(0)=y_0\sim\mathcal{N}(0.1,0.01)

and capture the uncertainty using Monte-Carlo simulation with M=1000M=1000 samples.

Loading...

The results of the predator-prey simulation are two timeseries, one for the prey and one for the predators, which are given for the common time-base [0,1,…,T][0,1,\dots,T]. That means, the MM results x⃗1,…,x⃗M\vec{x}_1,\dots,\vec{x}_M of the simulation are observations of a random vector X⃗∈(R+)2(T+1)\vec{X}\in \left(\mathbb{R}^+\right)^{2(T+1)}, in which the first T+1T+1 entries represent the quantity of prey animals for times [0,1,…,T][0,1,\dots,T] and the second the predator animals.

The most straight forward statistic that can be calculated from the results is the point-wise sample mean X‾M\overline{X}_M which approximates the unknown real mean μ⃗=E(X⃗)\vec{\mu}=\mathbb{E}(\vec{X}), i.e.

μ⃗≈X‾M=1M∑i=1Mx⃗i.\vec{\mu}\approx \overline{X}_M = \frac{1}{M}\sum_{i=1}^{M}\vec{x}_i.

By this point at the latest, one must be clear about the outcomes of interest. Suppose Y⃗=f(X⃗)\vec{Y}=f(\vec{X}) is a derived outcome, then

E(f(X⃗)) and f(E(X⃗))\mathbb{E}(f(\vec{X}))\text{ and }f\left(\mathbb{E}(\vec{X})\right)

are generally not equivalent. One example for the given case study is the maximum peak height:

f(X⃗)=(max(X⃗1T+1)max(X⃗T+22(T+1)))f(\vec{X})=\left(\begin{array}{c}max\left(\vec{X}_{1}^{T+1}\right)\\max\left(\vec{X}_{T+2}^{2(T+1)}\right)\end{array}\right)

for which E(f(X⃗))≠f(E(X⃗))\mathbb{E}(f(\vec{X}))\neq f\left(\mathbb{E}(\vec{X})\right).

Loading...
peaks of mean: (np.float64(1.3122723575543607), np.float64(0.8329920238429047))
mean of peaks: [np.float64(1.328956837488559), np.float64(0.8457135478131288)]

While the values are not far apart, they are clearly not equivalent. One lession here is that one should be careful when discarding the individually computed results from a Monte Carlo simulation. Retrospective calculation of statistics for derived outcomes may become impossible.

Finally, it is important to observe, for the same reason as before, that the mean of the simulation results is not necessarily equivalent to the (deterministic) simulation executed for the mean of the inputs.

Loading...

Quantification of Uncertainty

Now that we can calculate the expected value, it is time to quantify the uncertainties associated with the distribution. Given a list of results x⃗1,…,x⃗M\vec{x}_1,\dots,\vec{x}_M there are essentially two different approaches: parametric and non-parametric.

Uncertainty using Parametric Statistics

This parametric approach is based on the assumption that the results pointwise follow a known distribution D\mathcal{D} with parameters p1,…,pkp_1,\dots,p_k to be determined. We estimate the parameters from the individual Monte Carlo samples and use analytic knowledge from the distribution to quantify uncertianty measures such as confidence intervals.

The most common choice for such a distribution is the normal distribution N(μ,σ)\mathcal{N}(\mu,\sigma) with the two parameters mean μ\mu and standard deviation σ\sigma. This choice is particularly popular because it is often a reliable fit, and estimation of the parameters is quite simple: we already calculated the pointwise sample mean X⃗M\vec{X}_M and computation of the sample variance (and standarddeviation) is hardly more complicated:

σ⃗2≈s⃗M2=1M−1∑i=1M(x⃗i−X⃗M)2,\vec{\sigma}^2\approx\vec{s}_M^2=\frac{1}{M-1}\sum_{i=1}^{M}(\vec{x}_i-\vec{X}_M)^2,

whereas all computations must be understood pointwise. The factor 1M−1\frac{1}{M-1} instead of 1M\frac{1}{M} is used to make the estimator free of bias.

For a N(μ,σ)\mathcal{N}(\mu,\sigma) normally distributed XX we know

P(X<μ−σΦ−1(p))=pP\left(X<\mu-\sigma\Phi^{-1}(p)\right)=p

wheras Φ−1\Phi^{-1} is the inverse of the cumulative distribution function. As a result

[μ−Φ−1(p)σ,μ+Φ−1(p)σ]≈[X‾M−Φ−1(p)s⃗M2,X‾M+Φ−1(p)s⃗M2]\left[\mu-\Phi^{-1}(p)\sigma,\mu+\Phi^{-1}(p)\sigma\right]\approx \left[\overline{X}_M-\Phi^{-1}(p)\sqrt{\vec{s}^2_M},\overline{X}_M+\Phi^{-1}(p)\sqrt{\vec{s}^2_M}\right]

is a 100(1−2(1−p))%100(1-2(1-p))\% confidence interval. A confidence interval for a random variable XX derived from previous observations is usually called a prediction interval since it allows us to “predict” the value of XM+1X_{M+1} from previous observations X1,…,XMX_1,\dots,X_M.

Loading...

The confidence interval relies on the assumption that the Monte Carlo runs do indeed follow the given distribution. It is advisable to verify this on a random basis, for example by using a Gaussian kernel density estimatation (KDE) to estimate the empirical density.

Loading...
Loading...

It is well visible, that the distribution is quite skewed in particular when the curves are peaking. A log-normal distribution might be a better fit. Hereby X∼Lognormal(μ,σ2)X\sim Lognormal(\mu,\sigma^2) is defined by

X=eμ+σZX=e^{\mu+\sigma Z}

where ZZ follows a standard normal distribution. Since

E(X)=e(μ+σ2/2), and V(X)=(eσ2−1)e2μ+σ2\mathbb{E}(X)=e^{(\mu+\sigma^2/2)},\text{ and }\mathbb{V}(X)=(e^{\sigma^2}-1)e^{2\mu+\sigma^2}

we may estimate the two parameters μ\mu and σ\sigma from the empirical mean and variance via

μ=ln(X‾M2X‾M2+sM2), and σ2=ln(1+sM2X‾M2).\mu=ln\left(\frac{\overline{X}_M^2}{\sqrt{\overline{X}_M^2+s_M^2}}\right),\text{ and } \sigma^2=ln\left(1+\frac{s_M^2}{\overline{X}_M^2}\right).

Alternatively, it is also possible to automatically fit the distribution using a maximum likelihood method, as done below using lognorm.fit.

Loading...
Loading...

With the log-normal distributions the confidence/prediction bands are no longer symmetric which fits the real behaviour much better. Nevertheless, we must ask why we needed a proper distribution assumption in the first place. This motivates the idea for non-parametric approaches.

Uncertainty using Non-Parametric Statistics

The most generic approach to use non-parametric statistics for computation of confidence/prediction bands are the empirical quantiles. Loosely speaking we can say that a value qq is an empirical pp-quantile for a sample x1,…,xMx_1,\dots,x_M if

∣i:xi≤q∣≈p⋅M.|i:x_i\leq q|\approx p\cdot M.

For example, if p=0.5p=0.5 and M=101M=101 is uneven then the 51st51^{st} element of the ordered sample would be the unique proper choice for qq. However, if M=100M=100 any value greater the 50th50^{th} and smaller than the 51st51^{st} element would be eligible. Unfortunately, there is no unique solution what to do in these cases, most software packages including the numpy.quantile function compute an interpolation between the two values.

The p=0.5p=0.5 quantile is generally called the median and states that the random variable is smaller or larger with equal likelihood. While it is usally in the proximity of mean, it is only equivalent in case of symmetric distributions. The p=0.25p=0.25 and p=0.75p=0.75 quantiles are called quartiles and the span between the two is called interquartile range. It is a well established measure for uncertainty and, together with the median, the foundation of box-plots.

Loading...

Parametric or Non-Parametric

In principle, it is quite easy to choose between the two approaches. On the one hand, estimating confidence/prediction bands using quantiles is significantly more robust and always yields values within meaningful ranges. Moreover they do not require any assumptions on the underlying distribution. Unfortunately, they also require a comparably large sample size. If the number of sample is too small, corresponding curves may become very edgy and volatile. E.g. if M=100M=100 computing a p=0.01p=0.01 quantile relies on the value of the single smallest sample, which is clearly unstable.

On the other hand, parametric statistics can produce meaningful results even for smaller sample sizes (e.g. Conover (1999)). While M=100M=100 can be too small to estimate the quantile, it might be sufficient to estimate a standard deviation or to fit a distribution in general. Knowledge of the distribution properties and parameters can then provide additional informative value, such as tail behaviour or possibilities for extrapolation. However, a parametric estimate is only as good as the fit of the distribution. If the assumption regarding the distribution of the results is poor, the quantified uncertainty will also be incorrect.

Case-Study: Nonlinear-ODE - Proper Statistics?

We conclude this topic on uncertainty quantificatuon with a fictional case study. We assume that the dynamics of a system is described by the following non-linear initial-value problem:

x˙=−x(x−2)(x−α),x(0)=x0=1.0.\dot{x}=-x(x-2)(x-\alpha), x(0)=x_0=1.0.

To incproporate uncertainty, we use α∼N(1,0.02)\alpha \sim \mathcal{N}(1,0.02) and perform M=1000M=1000 samples.

Probability to be in part 1: 0.5080
Loading...

This fictional case study teaches us the important lesson that it is always important to choose the statistics carefully. The differential equation has a so-called bifurcation point at α\alpha. For x(t)<αx(t)<\alpha, the solution falls towards x≡0x\equiv 0, for x(t)>αx(t)>\alpha, the solution approaches x≡2x\equiv 2. Since α\alpha is distributed around the initial value x0=1x_0=1 this means that the solution curves are divided almost perfectly into two parts: one part in which the curves tend towards 0 and another in which they converge towards 2.

Plots 2 and 3 show that any statistical analysis carried out on the entire set of solution curves is virtually meaningless. The mean is almost exactly x≡1x\equiv 1 and is therefore not representative for any curve; the median is some arbitrary curve which goes up or down basically by coinflip. The standard deviation is enormous and the corresponding Gaussian interval is many times larger than the entire set of curves. Finally, also the empirical interval is also virtually meaningless. Only when the set of curves is divided properly, it is possible to perform proper analysis of the results.

It is therefore recommended that a statistical analysis should always be accompanied by a plot of the individual Monte Carlo runs in order to avoid such errors.

References
  1. Thrun, S., & Norvig, P. (2012). Introduction to artificial intelligence. Retrieved March, 19, 2012.
  2. Der Kiureghian, A., & Ditlevsen, O. (2009). Aleatory or epistemic? Does it matter? Structural Safety, 31(2), 105–112. 10.1016/j.strusafe.2008.06.020
  3. Slingo, J., & Palmer, T. (2011). Uncertainty in weather and climate prediction. Philosophical Transactions. Series A, Mathematical, Physical, and Engineering Sciences, 369(1956), 4751.
  4. Conover, W. J. (1999). Practical nonparametric statistics. john wiley & sons.