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, _fitting_scale=None, _is_transformed=None)¶
Parameter object for use in data fits, stores the initial value and bounds
Inherits from
pybamm.InputParameterfor compatibility with PyBaMM models. Like every PyBaMM symbol it is immutable once constructed: thewith_*methods (e.g.with_bounds()) return a changed copy instead.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.
- 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:
ConfigMixinSee also:
Parameter— field-level documentation.- 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
- 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.
- with_bounds(bounds, check_initial_value=True, check_bounds=True)¶
Return a copy of this parameter with different bounds.
Parameters¶
- boundstuple
The new
(lower, upper)bounds; either may be None for unbounded.- check_initial_valuebool, optional
Whether to check the initial value lies within the new bounds. Defaults to True.
- check_boundsbool, optional
Whether to check the new bounds are increasing. Defaults to True.
Returns¶
- Parameter
The new parameter. This one is unchanged.
- with_fitting_scale(fitting_scale=None)¶
Return a copy of this parameter with a different fitting scale.
Parameters¶
- fitting_scalefloat, optional
The scale factor the parameter is normalized by, used as its magnitude. None scales by the initial value. Ignored when
normalizeis False, where the scale is always 1.
Returns¶
- Parameter
The new parameter. This one is unchanged.
- with_initial_guess_distribution(initial_guess_distribution)¶
Return a copy of this parameter with a different initial guess distribution.
Parameters¶
- initial_guess_distributioniwp.stats.Uniform, iwp.stats.PointMass or None
The new distribution, which must lie within the bounds.
Returns¶
- Parameter
The new parameter. This one is unchanged.
- with_initial_value(initial_value, check_initial_value=True)¶
Return a copy of this parameter with a different initial value.
Parameters¶
- initial_valuefloat or None
The new initial value. None derives it from the bounds.
- check_initial_valuebool, optional
Whether to check the new value lies within the bounds. Defaults to True.
Returns¶
- Parameter
The new parameter. This one is unchanged.