RBD-FAST Sensitivity Analysis

This example demonstrates a RBD-FAST sensitivity analysis using the rbd_fast function from SALib (https://github.com/SALib/SALib). In this case, the sensitivity of the sum-of-squared errors (sse) to model parameters is evaluated. It is also possible to provide the name of an individual observation instead of the sse as an argument in the rbd_fast method (i.e., argument “obsname”).

import sys,os
import matk
import numpy as np
from matplotlib import pyplot as plt

# define a simple decaying sinusoidal function
def sine_decay(params, x, data):
    """ model decaying sine wave, subtract data"""
    amp = params['amp']
    shift = params['shift']
    omega = params['omega']
    decay = params['decay']

    model = amp * np.sin(x * omega + shift) * np.exp(-x*x*decay)

    obsnames = ['obs'+str(i) for i in range(1,len(data)+1)]
    return dict(zip(obsnames,model))


# create noisy data
x = np.linspace(0, 15, 301)
np.random.seed(1000)
data = (5. * np.sin(2 * x - 0.1) * np.exp(-x*x*0.025) +
        np.random.normal(size=len(x), scale=0.2) )

# Create MATK object
p = matk.matk(model=sine_decay, model_args=(x,data,))

# Create parameters
p.add_par('amp', value=10, min=0., max=20.)
p.add_par('decay', value=0.1, min=0, max=0.2)
p.add_par('shift', value=0.0, min=-np.pi/2., max=np.pi/2.)
p.add_par('omega', value=3.0, min=0, max=6)

# Create observation names and set observation values to noisy data
for i in range(len(data)):
    p.add_obs('obs'+str(i+1), value=data[i])

# Create LHS sample
ss1 = p.lhs(siz=1000)

# Execute the model on the LHS sample parameter combinations.
ss1.run(verbose=False)

# Perform the RBD_FAST analysis
SS = ss1.rbd_fast()
Parameter First
amp       0.404636
decay     0.27488
shift     0.00879554
omega     0.0190217
# Manually print some results
print SS['S1']
[0.4046356655403508, 0.2748798363210822, 0.0087955380299460373, 0.019021699707899017]

The results indicate that the model is most sensitive to “amp” followed by “decay”. The model is relatively insensitive to “shift” and “omega”.