pybop.parameters.parameter#
Module Contents#
Classes#
Represents a parameter within the PyBOP framework. |
- class pybop.parameters.parameter.Parameter(name, initial_value=None, prior=None, bounds=None)[source]#
Represents a parameter within the PyBOP framework.
This class encapsulates the definition of a parameter, including its name, prior distribution, initial value, bounds, and a margin to ensure the parameter stays within feasible limits during optimization or sampling.
- Parameters:
name (str) – The name of the parameter.
initial_value (float, optional) – The initial value to be assigned to the parameter. Defaults to None.
prior (scipy.stats distribution, optional) – The prior distribution from which parameter values are drawn. Defaults to None.
bounds (tuple, optional) – A tuple defining the lower and upper bounds for the parameter. Defaults to None.
- Raises:
ValueError – If the lower bound is not strictly less than the upper bound, or if the margin is set outside the interval (0, 1).
- __repr__()[source]#
Return a string representation of the Parameter instance.
- Returns:
A string including the parameter’s name, prior, bounds, and current value.
- Return type:
str
- rvs(n_samples)[source]#
Draw random samples from the parameter’s prior distribution.
The samples are constrained to be within the parameter’s bounds, excluding a predefined margin at the boundaries.
- Parameters:
n_samples (int) – The number of samples to draw.
- Returns:
An array of samples drawn from the prior distribution within the parameter’s bounds.
- Return type:
array-like
- set_margin(margin)[source]#
Set the margin to a specified positive value less than 1.
The margin is used to ensure parameter samples are not drawn exactly at the bounds, which may be problematic in some optimization or sampling algorithms.
- Parameters:
margin (float) – The new margin value to be used, which must be in the interval (0, 1).
- Raises:
ValueError – If the margin is not between 0 and 1.