Parameter¶
- class ionworkspipeline.Parameter(name, initial_value=None, bounds=None, prior=None, normalize=None, check_bounds=None, check_initial_value=None, initial_guess_distribution=None)¶
Parameter object for use in data fits, stores the initial value and bounds
Inherits from
pybamm.InputParameterfor compatibility with PyBaMM models.Parameters¶
- namestr
The name of the parameter.
- initial_valuefloat or int, optional
The initial value to be assigned to the parameter. If not provided and bounds are given, will be set to the mean of finite bounds. Defaults to 1 if no bounds are given.
- boundstuple, optional
A tuple defining the lower and upper bounds for the parameter. Defaults to (-np.inf, np.inf).
- prioriwp.stats.Distribution, optional
The prior distribution for the parameter.
- normalizebool, optional
Whether to normalize the parameter by its initial value. Defaults to True.
- fitting_scalefloat, optional
The scale factor for the parameter. If not provided, the parameter will be normalized by its initial value.
- check_boundsbool, optional
Whether to check the bounds of the parameter. Defaults to True.
- check_initial_valuebool, optional
Whether to check the initial value of the parameter. Defaults to True.
- initial_guess_distributioniwp.stats.Distribution, optional
The initial guess distribution for the parameter. Defaults to a uniform distribution between the bounds. The provided distribution must be either a iwp.stats.Uniform or iwp.stats.PointMass.
Extends:
ionworkspipeline.controllers.ConfigMixin- property base_parameter¶
Returns the base parameter
- property bounds¶
Returns the corrected parameter bounds
- get_bounds()¶
Returns the unmodified bounds
- get_initial_guess_distribution() Distribution | None¶
Returns the unmodified initial guess distribution for the parameter
- get_initial_value()¶
Returns the unmodified initial value
- property initial_guess_distribution: Distribution¶
Returns the initial guess distribution for the parameter
- property initial_value¶
Returns the corrected initial value
- property is_transformed¶
Returns whether the parameter represents a transformed variable.
Returns¶
- bool
True if the parameter is a transformed variable (e.g., “Log10(Diffusion Coefficient)”) False if the parameter is in its original form (e.g., “Diffusion Coefficient”)
Examples¶
>>> from ionworkspipeline.data_fits.parameter import Parameter >>> from ionworkspipeline.data_fits.transforms import Log10 >>> param = Parameter("Diffusion Coefficient", 1e-9, (1e-10, 1e-8)) >>> param.is_transformed False >>> transformed_param = Log10(param) >>> transformed_param.is_transformed True
- property prior¶
Returns the prior
- set_bounds(value, check_initial_value=True, check_bounds=True)¶
Sets the parameter bounds
- set_fitting_scale(value=None)¶
Sets the fitting scale for the parameter
Parameters¶
- valuefloat, optional
If the parameter is not normalized, the value to set the fitting scale to.
- set_initial_guess_distribution(initial_guess_distribution: Distribution | None)¶
Sets the initial guess distribution for the parameter
- set_prior(prior)¶
Sets the prior for the parameter
- to_config() dict¶
Convert the Parameter to a JSON-serializable configuration dictionary.
Returns a dictionary that can be used with parse_parameters() to reconstruct the parameter. The name field is excluded since it comes from the dictionary key in the parser.
Returns¶
- dict
Configuration dictionary with all initialization parameters, excluding validation-only parameters (check_bounds, check_initial_value) and name (which comes from the parser’s dict key).
- to_dict(name)¶
Convert the parameter to a dictionary for fitting.
This method is used by the DataFit class to process parameters for fitting. For a basic Parameter object, it simply returns a dictionary with one entry mapping the given name to this parameter object.
Parameters¶
- namestr
The name to use for the parameter in the model. This may be different from the parameter’s internal name.
Returns¶
- dict
A dictionary with a single entry mapping the given name to this parameter.