smash.Model.bayes_estimate#
- Model.bayes_estimate(sample=None, alpha=4, n=1000, random_state=None, jobs_fun='nse', wjobs_fun=None, event_seg=None, gauge='downstream', wgauge='mean', ost=None, ncpu=1, verbose=True, inplace=False, return_br=False)[source]#
Estimate prior Model parameters/states using Bayesian approach.
Hint
See the User Guide and Math / Num Documentation for more.
- Parameters:
- sampleSampleResult or None, default None
An instance of the
SampleResultobject, which should be created using thesmash.generate_samplesmethod.Note
If not given, the Model parameters samples will be generated automatically using the uniform generator based on the Model structure considered.
- alphaint, float or sequence, default 4
A regularization parameter that controls the decay rate of the likelihood function.
Note
If alpha is a sequence, then the L-curve approach will be used to find an optimal value for the regularization parameter.
- nint, default 1000
Number of generated samples. Only used if sample is not set.
- random_stateint or None, default None
Random seed used to generate samples. Only used if sample is not set.
Note
If not given and sample is not set, generates the parameters set with a random seed.
- jobs_fun, wjobs_fun, event_seg, gauge, wgauge, ostmultiple types
Optimization setting to run the forward hydrological model and compute the cost values. See
smash.Model.optimizefor more.- ncpuinteger, default 1
If ncpu > 1, perform a parallel computation through the parameters set.
- verbosebool, default True
Display information while estimating.
- inplacebool, default False
If True, perform operation in-place.
- return_brbool, default False
If True, also return the Bayesian estimation result
BayesResult.
- Returns:
- ModelModel or None
Model with optimize outputs if not inplace.
- resBayesResult
The Bayesian estimation results represented as a
BayesResultobject if return_br.
See also
BayesResultRepresents the Bayesian estimation or optimization result.
SampleResultRepresents the generated sample result.
Examples
>>> setup, mesh = smash.load_dataset("cance") >>> model = smash.Model(setup, mesh) >>> br = model.bayes_estimate(n=200, inplace=True, return_br=True, random_state=99)
Access to cost values of the direct simulations
>>> cost = br.data["cost"] >>> cost.sort() # sort the values by ascending order >>> cost array([4.88620669e-01, 5.70850313e-01, 7.37333179e-01, 7.59980202e-01, ... 9.26341797e+03, 1.12409111e+04, 1.13607480e+04, 1.18410371e+04])
Compare to the cost value of the Model with the estimated parameters using Bayesian apporach
>>> model.output.cost 0.41908782720565796