A CompartmentalModel with an additional get_noise member.
More...
#include <stochastic_model.h>
|
| using | Base = std::conditional_t< std::is_same_v< Flows, void >, CompartmentalModel< FP, Comp, Pop, Params >, FlowModel< FP, Comp, Pop, Params, Flows > > |
| |
|
| virtual void | get_noise (Eigen::Ref< const Eigen::VectorX< FP >>, Eigen::Ref< const Eigen::VectorX< FP >>, FP, Eigen::Ref< Eigen::VectorX< FP >>) const |
| | Calculate random changes to the population at a certain time point. More...
|
| |
| RandomNumberGenerator & | get_rng () const |
| | Access the model's RNG. More...
|
| |
| FP | sample_standard_normal_distribution () const |
| | Sample a standard normal distributed value from the model's RNG. More...
|
| |
| auto | white_noise (Eigen::Index size) const |
| | Sample a vector of independent standard normal distributed values from the model's RNG. More...
|
| |
|
| RandomNumberGenerator | m_rng |
| | RNG for generating white noise in the get_noise implementation. More...
|
| |
template<typename FP, class Comp, class Pop, class Params, class Flows = void>
class mio::StochasticModel< FP, Comp, Pop, Params, Flows >
A CompartmentalModel with an additional get_noise member.
◆ Base
template<typename FP , class Comp , class Pop , class Params , class Flows = void>
| using mio::StochasticModel< FP, Comp, Pop, Params, Flows >::Base = std::conditional_t<std::is_same_v<Flows, void>, CompartmentalModel<FP, Comp, Pop, Params>, FlowModel<FP, Comp, Pop, Params, Flows> > |
◆ get_noise()
template<typename FP , class Comp , class Pop , class Params , class Flows = void>
| virtual void mio::StochasticModel< FP, Comp, Pop, Params, Flows >::get_noise |
( |
Eigen::Ref< const Eigen::VectorX< FP >> |
, |
|
|
Eigen::Ref< const Eigen::VectorX< FP >> |
, |
|
|
FP |
, |
|
|
Eigen::Ref< Eigen::VectorX< FP >> |
|
|
) |
| const |
|
inlinevirtual |
Calculate random changes to the population at a certain time point.
This function calculates the random noise part of an SDE model. In general, it represents the result of the deterministic noise matrix multiplied by a white noise vector.
For infectious disease models, the noise matrix usually maps noise contributions from each flow to their respective compartments. In that case, the white noise vector has size #flows. The resulting noise vector must have the same size as the state vector y. This is due to the fact that the integration of SDE models must happen on populations, not flows, as the applied noise can occassionally push compartments into negative values. This can be mitigated by removing negative values and rescaling the population (see map_to_nonnegative), but this mitigation can not (in general) be applied to flows. The noise must still be applied per flow, so both inflow and outflow use the same random value. Otherwise, transitions between compartments would no longer preserve the total population count.
Reimplemented in mio::ssirs::Model< FP >, mio::ssir::Model< FP >, and mio::sseirvv::Model< FP >.
◆ get_rng()
template<typename FP , class Comp , class Pop , class Params , class Flows = void>
◆ sample_standard_normal_distribution()
template<typename FP , class Comp , class Pop , class Params , class Flows = void>
| FP mio::StochasticModel< FP, Comp, Pop, Params, Flows >::sample_standard_normal_distribution |
( |
| ) |
const |
|
inline |
Sample a standard normal distributed value from the model's RNG.
For a vector of random values, use white_noise. Note that the value is always drawn as a double, and then converted to FP.
- Returns
- A random value.
◆ white_noise()
template<typename FP , class Comp , class Pop , class Params , class Flows = void>
Sample a vector of independent standard normal distributed values from the model's RNG.
- Parameters
-
| size | The size of the vector. Useful for vector arithmetic. For single random values, use sample_standard_normal_distribution. |
- Returns
- A random vector (expression calling sample_standard_normal_distribution for each entry).
◆ m_rng
template<typename FP , class Comp , class Pop , class Params , class Flows = void>
RNG for generating white noise in the get_noise implementation.