Monte Carlo simulation

Monte Carlo simulation#

TODO#

Todo

Write this section.

classmethod flx.sampler.perform_MCS()#

This method requires an object of type flx.sampler.

Syntax:

flx.sampler.perform_MCS(N, VFUN, DBOX)

Description:

Perform a Monte Carlo simulation.

Parameters:
  • N (int) – The total number of samples to generate in the Monte Carlo simulation. Must be a value larger than zero.

  • VFUN (flxVecPara) – The model; i.e., a vector-valued function that depends on the input random variables of this sampler.

  • DBOX (flx.dataBox) – A data-box that handles the post-processing of the generated samples.

Return type:

None

Example:

import fesslix as flx
flx.load_engine()
Random Number Generator: MT19937 - initialized with rand()=128734470;
Random Number Generator: MT19937 - initialized with 1000 initial calls.
0
## ==============================================
## Generate input model
## ==============================================
config_rv_R = { 'name':'R', 'type':'logn', 'mu':6., 'sd':1. }
config_rv_S = { 'name':'S', 'type':'normal', 'mu':1., 'sd':1. }
rv_set = flx.rv_set( {'name':'rv_set'}, [ config_rv_R, config_rv_S ] )
sampler = flx.sampler(['rv_set'])
## ==============================================
## Generate output model
## ==============================================
model = [ "rbrv(rv_set::R)-rbrv(rv_set::S)" ]
## ==============================================
## Set up dataBox
## ==============================================
dBox = flx.dataBox(2,1)
pp_rel = dBox.register_post_processor({ 'type':'reliability', 'col':{ 'set':'out', 'id':0} })
## ==============================================
## Perform the Monte Carlo simulation
## ==============================================
sampler.perform_MCS(100000,model,dBox)
## ==============================================
## Post-processing
## ==============================================
pp_rel_res = pp_rel.eval()
print( pp_rel_res )
{'N': 100000, 'H': 6, 'mean_freq': 6e-05, 'rv_pf': <fesslix.core.rv object at 0x78326f5c8730>, 'mean_bayes': 6.999860002799944e-05}