Stochasticmodel API Reference
pyfastwell.stochastic.stochasticmodel.Stochasticmodel
Bases: object
Stochastic model for parameter sampling and forward modeling.
This class manages model parameters, samples them according to specified distributions, and applies them to a forward model for ensemble simulations.
Notes
- Locked parameters remain constant across the ensemble.
- Free parameters are sampled according to their specified distributions.
- The class supports normal, uniform, and triangular distributions for sampling.
__init__
Initialize the Stochasticmodel object.
Parameters:
argdict: dictionary with keys 'locked', 'free_param', and 'free dist' containing the model parameters
Notes
The model parameters are subdivided in 'locked' parameters, which typically include the time array for which simulation is performed and additional 'locked' parameters which are not variable for the ensemble. The 'free_parameters' contains a list of parameter names which are allowed to vary and are sampled for the Stochasticmodel corresponding to the 'free_dist' distribition specifications
get_from_dict
Get a parameter from the dictionary based on its name, either from 'locked' or 'free_param' If the name is not found in 'free_param', it will look in 'locked'. If the name is not found in either, it will raise an exception. This method is used to retrieve the parameter values for the ensemble realisations.
Parameters
name: name of the parameter to be retrieved from the dictionary (either 'locked' or 'free_param'), 'free_param' takes prevalence
param: ensembles realisation corresponding to 'free_param' sampled values
Returns
value of the parameter corresponding to the name, either from 'locked' or from 'free_param'
getmedianparams
Get the median values of the free parameters
Returns
median values of the free parameters in one dimensional array
generate_ensemble
Generate an ensemble of model parameters based on the distribution specifications in the dictionary
Parameters
nsamples: number of samples to generate
Returns
list of parameter arrays (dimension equal to number of free parameters), list size equal to nsamples
run_ensemble
Run the forward model for the ensemble of parameters
Parameters
m: ensemble of parameters, corresponding to the free parameters and created by generate_ensemble forward: forward model function
Returns
results of the forward model for the ensemble
plot_distribution
Plot the distribution of a parameter forward model results
Parameters:
results: results of the forward model for the ensemble ndarray
name: name of the plot
Returns
None
expectation_plot
expectation_plot(results: ndarray, name: str, percent: bool = True, expectation: bool = True, pvals: Optional[List[float]] = None) -> None
Plot the expectation of a parameter forward model results
Parameters
results: results of the forward model for the ensemble ndarray
name: name of the plot
percent: if True, the y-axis is in percent, otherwise in fraction
expectation: if True, the y-axis is reversed interpreting the results as expectation
pvals: pvalues to be plotted (list)
Returns
None