rcrpy.Priors¶
- class rcrpy.Priors(prior_type=None, p=None, gaussian_params=None, param_bounds=None)[source]¶
Bases:
objectProbabilistic priors on model parameters.
Mirrors the C++ Priors class (cpp/src/FunctionalForm.h:22). Four modes:
GAUSSIAN: gaussian_params[i] = (mu_i, sigma_i). NaN values mean no prior on that param. Implemented as quadratic penalty residuals (params[i] - mu_i) / sigma_i appended to the least-squares residual.CONSTRAINED: param_bounds[i] = (lb_i, ub_i). NaN means unbounded on that side. Wired into scipy.optimize.least_squares as its bounds= argument.MIXED: both Gaussian and Constrained simultaneously.CUSTOM: user supplies p(params) -> ndarray which is appended to the residual vector verbatim (allows arbitrary log-posterior shape).
Construct with the appropriate mode + data; the regression() routine in FunctionalForm reads prior_type, gaussian_params, param_bounds, and p as needed.
- Parameters:
Methods
__init__([prior_type, p, gaussian_params, ...])gaussian_residuals(params)For active Gaussian priors, return (params[i] - mu) / sigma for each param with a defined (non-NaN) prior.
scipy_bounds(n_params)Convert param_bounds into the (low, high) arrays scipy expects (with np.inf substituted for NaN — i.e. unbounded).