nlsq.precision.bound_inference.BoundsInference¶
- class nlsq.precision.bound_inference.BoundsInference(xdata, ydata, p0, safety_factor=10.0, enforce_positivity=True)[source]¶
Bases:
objectInfer reasonable parameter bounds from data characteristics.
This class implements heuristics to estimate parameter bounds that help constrain optimization without being overly restrictive. The bounds are based on data ranges, parameter scales, and common patterns.
- Parameters:
xdata (array_like) – Independent variable data
ydata (array_like) – Dependent variable data
p0 (array_like) – Initial parameter guess
safety_factor (float, optional) – Multiplier for bound ranges (larger = more conservative). Default: 10.0
enforce_positivity (bool, optional) – Force all bounds to be non-negative if p0 is positive. Default: True
- x_min, x_max
Range of independent variable
- Type:
- y_min, y_max
Range of dependent variable
- Type:
- x_range, y_range
Span of data
- Type:
Examples
>>> x = np.linspace(0, 10, 100) >>> y = 2.5 * np.exp(-0.5 * x) + 1.0 >>> p0 = [2.0, 0.5, 1.0] >>> >>> inference = BoundsInference(x, y, p0) >>> bounds = inference.infer() >>> print(bounds) ([0.0, 0.0, 0.0], [25.0, 5.0, 10.0])