$${\frac {dS}{dt}}=-{\frac {\beta SI}{N}}$$$${\displaystyle {\frac {dI}{dt}}={\frac {\beta SI}{N}}-\gamma I}$$$${\displaystyle {\frac {dR}{dt}}=\gamma I}$$

`input_file`

is a JSON file of the following format: `{"outfile": "$outfile", "S0": $S0, "I0": $I0, "beta": $beta, "gamma": $gamma, "iterations": $iterations}`

`sir <input_file>`

Lets try and run it.

In [1]:

```
!echo "{\"outfile\": \"output.csv\", \"S0\": 997, \"I0\": 3, \"beta\": 0.2, \"gamma\": 0.04, \"iterations\": 100}" > input.json
```

In [2]:

```
!./sir input.json
```

In [3]:

```
!head output.csv
```

Finally lets plot the results.

In [4]:

```
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('output.csv')
```

In [5]:

```
plt.plot(df['S'], label='S')
plt.plot(df['I'], label='I')
plt.plot(df['R'], label='R')
plt.legend()
```

Out[5]:

<matplotlib.legend.Legend at 0x11dd68d00>

In [6]:

```
import easyvvuq as uq
import chaospy as cp
import matplotlib.pyplot as plt
```

In [7]:

```
params = {
"S0": {"type": "float", "default": 997},
"I0": {"type": "float", "default": 3},
"beta": {"type": "float", "default": 0.2},
"gamma": {"type": "float", "default": 0.04, "min": 0.0, "max": 1.0},
"iterations": {"type": "integer", "default": 100},
"outfile": {"type": "string", "default": "output.csv"}
}
```

`SimpleCSV`

decoder. The arguments to it should be self explanatory.

In [8]:

```
encoder = uq.encoders.GenericEncoder(template_fname='sir.template', delimiter='$', target_filename='input.json')
decoder = uq.decoders.SimpleCSV(target_filename='output.csv', output_columns=['I'])
```

In [9]:

```
campaign = uq.Campaign(name='sir', params=params, encoder=encoder, decoder=decoder)
```

In [10]:

```
vary = {
"beta": cp.Uniform(0.15, 0.25),
"gamma": cp.Normal(0.04, 0.01),
}
```

In [11]:

```
campaign.set_sampler(uq.sampling.PCESampler(vary=vary, polynomial_order=5))
```

In [12]:

```
execution = campaign.sample_and_apply(action=uq.actions.ExecuteLocalV2("sir input.json"), batch_size=8)
```

In [13]:

```
execution.start();
```

In [17]:

```
execution.progress()
```

Out[17]:

{'ready': 0, 'active': 0, 'finished': 36, 'failed': 0}

In [18]:

```
result = campaign.analyse(qoi_cols=['I'])
```

`beta`

and `gamma`

) have over the number of people infected over time `t`

. The `higher orders`

line is meant to represent the influence of the interactions between the input variables. However it is negligible in this case.

In [19]:

```
result.plot_sobols_first('I', xlabel='t')
```

Out[19]:

<AxesSubplot:xlabel='t', ylabel='First Order Sobol Index'>

`vary`

dictionary.

In [20]:

```
result.plot_moments('I', xlabel='t')
```

Out[20]:

<AxesSubplot:xlabel='t', ylabel='I'>

In [ ]:

```
result.sobols_first('I')
```

In [ ]:

```
result.describe('I', 'mean')
```

In [ ]:

```
result.describe('I', 'std')
```

In [ ]:

```
result.describe('I', '1%')
```

In [ ]:

```
result.describe('I', '99%')
```