Loading...
Searching...
No Matches
Scalar GP and Bayesian quadrature (ABI 1.17)

Functions

gpr_bq_t gpr_bq_create (const gpr_bq_config_t *config)
 Create a scalar GP / Bayesian quadrature handle.
void gpr_bq_destroy (gpr_bq_t bq)
 Destroy a handle from gpr_bq_create. Destroying NULL or a live handle clears gpr_last_status() and gpr_last_error(), while preserving a pending GPR_ERR_ORACLE during cleanup. A handle that is already destroyed is not touched and sets GPR_ERR_INVALID_ARG in gpr_last_status().
int gpr_bq_reset (gpr_bq_t bq, const gpr_bq_config_t *config)
 Replace the configuration and drop every observation and any stored integration box.
int gpr_bq_dimension (gpr_bq_t bq)
 Input dimension of the configuration; 0 for NULL or a dead handle.
int gpr_bq_n_observations (gpr_bq_t bq)
 Number of stored observations; 0 for NULL or a dead handle.
int gpr_bq_n_lengthscales (gpr_bq_t bq)
 Number of length scales: dimension when the configuration is ARD, otherwise 1; 0 for NULL or a dead handle.
int gpr_bq_train_checked (gpr_bq_t bq, const double *X, size_t X_len, const double *y, size_t y_len, const double *noise_var, size_t noise_var_len, int n_obs, int n_dims)
 Train on n_obs points and infer the integration box from the training extrema.
int gpr_bq_train_bounded_checked (gpr_bq_t bq, const double *X, size_t X_len, const double *y, size_t y_len, const double *noise_var, size_t noise_var_len, const double *lower, size_t lower_len, const double *upper, size_t upper_len, int n_obs, int n_dims)
 Train and store an explicit integration box. Each lower[d] is finite and strictly below upper[d], and every training coordinate lies in the closed interval. Null noise_var with a zero length stores zero noise, as gpr_bq_train_checked does. The box is kept for later refits and for appended rows.
int gpr_bq_append_checked (gpr_bq_t bq, const double *X_new, size_t X_len, const double *y_new, size_t y_len, const double *noise_var_new, size_t noise_var_len, int n_new, int n_dims, int refit)
 Append n_new observations to a trained model.
int gpr_bq_fit_hyperparameters_checked (gpr_bq_t bq, gpr_bq_hyper_mode_t mode, gpr_bq_fit_report_t *report, double *lengthscales_out, size_t lengthscales_len)
 Re-infer the hyperparameters of a trained model with the given treatment, which then becomes the configured treatment.
int gpr_bq_get_lengthscales_checked (gpr_bq_t bq, double *out, size_t out_len)
 Copy the current length scales out.
int gpr_bq_set_lengthscales_checked (gpr_bq_t bq, const double *values, size_t values_len)
 Pin the length scales. A trained model is rebuilt with them held and the signal variance kept at its current value; the observations and the configured hyperparameter treatment stay unchanged.
int gpr_bq_get_magn_sigma2 (gpr_bq_t bq, double *out)
 Signal variance of the posterior (squared output unit). out receives one double.
int gpr_bq_set_magn_sigma2 (gpr_bq_t bq, double value)
 Pin the signal variance. A trained model is rebuilt with it held and the length scales kept (an ARD set stays anisotropic); the configured hyperparameter treatment stays unchanged.
int gpr_bq_get_extra_sigma2 (gpr_bq_t bq, double *out)
 Extra observation-noise variance added to every observation. out receives one double.
int gpr_bq_set_extra_sigma2 (gpr_bq_t bq, double value)
 Set the extra observation-noise variance. A trained model is refit with its configured hyperparameter treatment.
int gpr_bq_predict_batch_checked (gpr_bq_t bq, const double *X_queries, size_t X_len, double *mean_out, size_t mean_len, double *var_out, size_t var_len, int n_queries, int n_dims)
 Posterior mean and variance at n_queries points.
int gpr_bq_kernel_mean_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, const double *X, size_t X_len, int n_points, int n_dims, double *z_out, size_t z_len)
 Kernel mean z_i = integral over the box [lower, upper] of k(x, X_i) dx, at the training points or at explicit points.
int gpr_bq_kernel_double_integral_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, int n_dims, double *omega_out)
 Kernel double integral of k over the box, written to *omega_out (output unit squared times volume squared). Same readiness rule as gpr_bq_kernel_mean_checked.
int gpr_bq_integrate_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, int n_dims, double *mean_out, double *var_out)
 Integral mean and variance over a box. Equivalent to gpr_bq_integrate_report_checked keeping only mean and variance.
int gpr_bq_integrate_report_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, int n_dims, gpr_bq_integral_report_t *report)
 Integral over a box with the full decomposition of the variance.
int gpr_bq_integrate_measure_checked (gpr_bq_t bq, int kind, const double *lower, size_t lower_len, const double *upper, size_t upper_len, const double *mean, size_t mean_len, const double *covariance, size_t covariance_len, int n_dims, double *mean_out, double *var_out, double *mass_out)
 Integrate against a Lebesgue box, the uniform probability on that box, or a Gaussian.
int gpr_bq_integrate_uncertainty_checked (gpr_bq_t bq, int kind, const double *lower, size_t lower_len, const double *upper, size_t upper_len, const double *mean, size_t mean_len, const double *covariance, size_t covariance_len, int n_dims, gpr_bq_uncertainty_t *report)
 As gpr_bq_integrate_measure_checked, with the uncertainty split by source. Same measure arguments and failures.
int gpr_bq_set_basis (gpr_bq_t bq, int basis)
 Select the Bayes-Sard mean model with a gpr_bq_basis_t value; GPR_BQ_BASIS_FOLLOW_CONFIG (-1) follows the configuration (use_prior_mean: constant when set, none otherwise). A trained model is rebuilt with the new basis.
int gpr_bq_get_basis (gpr_bq_t bq, int *basis_out)
 Active basis selection, a gpr_bq_basis_t value written to *basis_out (GPR_BQ_BASIS_FOLLOW_CONFIG until a basis is set).
int gpr_bq_integrate_cumulative_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper_limits, size_t upper_limits_len, int n_limits, int n_dims, double *mean_out, size_t mean_len, double *covariance_out, size_t covariance_len)
 Joint posterior of the integrals over [lower, upper_limits[j]] for n_limits nested upper limits.
int gpr_bq_sample_cumulative_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper_limits, size_t upper_limits_len, int n_limits, int n_dims, int n_draws, uint64_t seed, double *draws_out, size_t draws_len)
 Draw n_draws joint samples of the cumulative integrals, deterministic in seed.
int gpr_bq_candidate_variance_reduction_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, const double *X_candidates, size_t X_cand_len, const double *cand_noise_var, size_t cand_noise_len, int n_candidates, int n_dims, double *delta_var_out, size_t delta_var_len)
 Variance reduction of the integral from one extra observation at each candidate.
int gpr_bq_select_batch_candidates_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, const double *X_candidates, size_t X_cand_len, const double *cand_noise_var, size_t cand_noise_len, int n_candidates, int n_dims, int batch_size, int *selected_indices_out, size_t selected_indices_len, double *step_reductions_out, size_t step_reductions_len)
 Greedily choose batch_size candidates, each conditioned on the ones chosen before it.
int gpr_bq_calibrate_loo_checked (gpr_bq_t bq, double nominal_probability, gpr_calibration_report_t *report)
 Closed-form leave-one-out calibration summary at the given central probability in (0, 1). It makes no oracle call and does not change the model.
int gpr_bq_calibrate_loo_scores_checked (gpr_bq_t bq, double nominal_probability, gpr_bq_loo_report_t *report, double *z_scores_out, size_t z_scores_len)
 As gpr_bq_calibrate_loo_checked, and also write every standardized leave-one-out score.

Detailed Description

A gpr_bq_t holds one scalar Gaussian process over dimension inputs and integrates it in closed form over a box or a Gaussian measure.

Ownership. gpr_bq_create returns a handle that the caller owns until it passes it to gpr_bq_destroy. Every pointer argument is read or written during the call and stays with the caller; the library copies what it keeps. Row-major flat arrays hold points, one row per point.

Single writer. A gpr_bq_t has one writer at a time. A call that changes the handle (gpr_bq_reset, the train, append and fit calls, the set_* calls and gpr_bq_destroy) must not overlap any other call on the same handle. The library takes no lock on the handle; the table that tells a live handle from a destroyed one has its own mutex, so calls on distinct handles may run on different threads at once. A destroyed handle is refused: a second gpr_bq_destroy sets GPR_ERR_INVALID_ARG in gpr_last_status(), and any other call returns GPR_ERR_NULL_HANDLE (the query functions return 0).

Failure. Every function that returns int returns GPR_SUCCESS (0) or a negative status and leaves its output buffers unwritten on failure. A _checked function takes the length of each caller buffer in doubles and returns GPR_ERR_INVALID_ARG for a short one. GPR_ERR_NOT_TRAINED means the call needs observations. GPR_ERR_CHOLESKY means that the covariance is singular or not positive definite at the hyperparameters the call uses, as when two observations share a location and the noise is zero; a train, append or set function returns it with the model unchanged. Other BayesianQuadratureInferenceError failures, including an eigensolver failure, return GPR_ERR_OPTIMIZER. GPR_ERR_OPTIMIZER means that hyperparameter inference failed (including the case that every trial point of the optimizer failed) and the model kept its previous state; the library does not substitute another treatment.

Function Documentation

◆ gpr_bq_append_checked()

int gpr_bq_append_checked ( gpr_bq_t bq,
const double * X_new,
size_t X_len,
const double * y_new,
size_t y_len,
const double * noise_var_new,
size_t noise_var_len,
int n_new,
int n_dims,
int refit )

Append n_new observations to a trained model.

Parameters
refitNonzero re-infers the hyperparameters with the configured treatment; zero keeps the current length scales and signal variance.
bqBayesian quadrature handle.
X_newRow-major coordinates of the observations to append.
X_lenLength of X_new in elements.
y_newValues at the coordinates to append.
y_lenLength of y_new in elements.
noise_var_newNew observation variances, or NULL with length zero for zero noise.
noise_var_lenLength of noise_var_new in elements.
n_newNumber of observations to append.
n_dimsNumber of coordinates per point; equals the handle dimension.
Returns
As gpr_bq_train_checked, plus GPR_ERR_NOT_TRAINED before a train. A stored box rejects a row outside it with GPR_ERR_INVALID_ARG.

◆ gpr_bq_calibrate_loo_checked()

int gpr_bq_calibrate_loo_checked ( gpr_bq_t bq,
double nominal_probability,
gpr_calibration_report_t * report )

Closed-form leave-one-out calibration summary at the given central probability in (0, 1). It makes no oracle call and does not change the model.

Parameters
reportOne struct written on success.
bqBayesian quadrature handle.
nominal_probabilityCentral interval probability, strictly between zero and one.

◆ gpr_bq_calibrate_loo_scores_checked()

int gpr_bq_calibrate_loo_scores_checked ( gpr_bq_t bq,
double nominal_probability,
gpr_bq_loo_report_t * report,
double * z_scores_out,
size_t z_scores_len )

As gpr_bq_calibrate_loo_checked, and also write every standardized leave-one-out score.

Parameters
z_scores_outgpr_bq_n_observations() doubles (z_scores_len).
bqBayesian quadrature handle.
nominal_probabilityCentral interval probability, strictly between zero and one.
reportCalibration summary written on success.
z_scores_lenLength of z_scores_out in elements.

◆ gpr_bq_candidate_variance_reduction_checked()

int gpr_bq_candidate_variance_reduction_checked ( gpr_bq_t bq,
const double * lower,
size_t lower_len,
const double * upper,
size_t upper_len,
const double * X_candidates,
size_t X_cand_len,
const double * cand_noise_var,
size_t cand_noise_len,
int n_candidates,
int n_dims,
double * delta_var_out,
size_t delta_var_len )

Variance reduction of the integral from one extra observation at each candidate.

Parameters
X_candidatesn_candidates * n_dims row-major.
cand_noise_varn_candidates non-negative variances, or NULL with length 0 for the configured candidate noise.
delta_var_outn_candidates doubles (delta_var_len).
bqBayesian quadrature handle.
lowerLower integration bounds, one per coordinate.
lower_lenLength of lower in elements.
upperUpper integration bounds, one per coordinate.
upper_lenLength of upper in elements.
X_cand_lenLength of X_candidates in elements.
cand_noise_lenLength of cand_noise_var in elements.
n_candidatesNumber of candidate points.
n_dimsNumber of coordinates per point; equals the handle dimension.
delta_var_lenLength of delta_var_out in elements.

◆ gpr_bq_create()

gpr_bq_t gpr_bq_create ( const gpr_bq_config_t * config)

Create a scalar GP / Bayesian quadrature handle.

Parameters
configCopied; NULL selects gpr_bq_config_defaults(). Fields are validated (positive dimension, finite non-negative scales).
Returns
A new handle owned by the caller, or NULL with the status and message in gpr_last_status() / gpr_last_error(): GPR_ERR_INVALID_ARG for an invalid configuration, or GPR_ERR_UNSUPPORTED for an unsupported configuration (std::domain_error).

◆ gpr_bq_destroy()

void gpr_bq_destroy ( gpr_bq_t bq)

Destroy a handle from gpr_bq_create. Destroying NULL or a live handle clears gpr_last_status() and gpr_last_error(), while preserving a pending GPR_ERR_ORACLE during cleanup. A handle that is already destroyed is not touched and sets GPR_ERR_INVALID_ARG in gpr_last_status().

◆ gpr_bq_dimension()

int gpr_bq_dimension ( gpr_bq_t bq)

Input dimension of the configuration; 0 for NULL or a dead handle.

◆ gpr_bq_fit_hyperparameters_checked()

int gpr_bq_fit_hyperparameters_checked ( gpr_bq_t bq,
gpr_bq_hyper_mode_t mode,
gpr_bq_fit_report_t * report,
double * lengthscales_out,
size_t lengthscales_len )

Re-infer the hyperparameters of a trained model with the given treatment, which then becomes the configured treatment.

Parameters
reportOptional fit report (may be NULL); see gpr_bq_fit_report_t, including failed_trials.
lengthscales_outOptional; receives gpr_bq_n_lengthscales() values (lengthscales_len doubles). NULL needs length 0.
bqBayesian quadrature handle.
modeHyperparameter treatment to use for the fit.
lengthscales_lenLength of lengthscales_out in elements.
Returns
GPR_SUCCESS; GPR_ERR_NULL_HANDLE; GPR_ERR_NOT_TRAINED; GPR_ERR_INVALID_ARG for an invalid treatment or output buffer; GPR_ERR_OPTIMIZER when the fit does not produce a finite posterior (the model is unchanged); GPR_ERR_CHOLESKY for a covariance that does not factor at fixed hyperparameters; GPR_ERR_ALLOC and GPR_ERR_SIZE_LIMIT keep their own status, and another runtime error is GPR_ERR_INTERNAL.

◆ gpr_bq_get_basis()

int gpr_bq_get_basis ( gpr_bq_t bq,
int * basis_out )

Active basis selection, a gpr_bq_basis_t value written to *basis_out (GPR_BQ_BASIS_FOLLOW_CONFIG until a basis is set).

◆ gpr_bq_get_extra_sigma2()

int gpr_bq_get_extra_sigma2 ( gpr_bq_t bq,
double * out )

Extra observation-noise variance added to every observation. out receives one double.

◆ gpr_bq_get_lengthscales_checked()

int gpr_bq_get_lengthscales_checked ( gpr_bq_t bq,
double * out,
size_t out_len )

Copy the current length scales out.

Parameters
outgpr_bq_n_lengthscales() doubles (out_len doubles). Before a train these are the configured values.
bqBayesian quadrature handle.
out_lenLength of out in elements.

◆ gpr_bq_get_magn_sigma2()

int gpr_bq_get_magn_sigma2 ( gpr_bq_t bq,
double * out )

Signal variance of the posterior (squared output unit). out receives one double.

◆ gpr_bq_integrate_checked()

int gpr_bq_integrate_checked ( gpr_bq_t bq,
const double * lower,
size_t lower_len,
const double * upper,
size_t upper_len,
int n_dims,
double * mean_out,
double * var_out )

Integral mean and variance over a box. Equivalent to gpr_bq_integrate_report_checked keeping only mean and variance.

Parameters
mean_out,var_outOne double each.
bqBayesian quadrature handle.
lowerLower integration bounds, one per coordinate.
lower_lenLength of lower in elements.
upperUpper integration bounds, one per coordinate.
upper_lenLength of upper in elements.
n_dimsNumber of coordinates per point; equals the handle dimension.
Returns
GPR_SUCCESS; GPR_ERR_NOT_TRAINED; GPR_ERR_INVALID_ARG; GPR_ERR_INTERNAL for another integration exception.

◆ gpr_bq_integrate_cumulative_checked()

int gpr_bq_integrate_cumulative_checked ( gpr_bq_t bq,
const double * lower,
size_t lower_len,
const double * upper_limits,
size_t upper_limits_len,
int n_limits,
int n_dims,
double * mean_out,
size_t mean_len,
double * covariance_out,
size_t covariance_len )

Joint posterior of the integrals over [lower, upper_limits[j]] for n_limits nested upper limits.

Parameters
upper_limitsn_limits * n_dims row-major (upper_limits_len).
mean_outn_limits doubles (mean_len).
covariance_outn_limits * n_limits row-major (covariance_len); symmetric positive semidefinite, its diagonal the marginal variances of gpr_bq_integrate_checked to roundoff.
bqBayesian quadrature handle.
lowerLower integration bounds, one per coordinate.
lower_lenLength of lower in elements.
upper_limits_lenLength of upper_limits in elements.
n_limitsNumber of nested upper limits.
n_dimsNumber of coordinates per point; equals the handle dimension.
mean_lenLength of mean_out in elements.
covariance_lenLength of covariance_out in elements.

◆ gpr_bq_integrate_measure_checked()

int gpr_bq_integrate_measure_checked ( gpr_bq_t bq,
int kind,
const double * lower,
size_t lower_len,
const double * upper,
size_t upper_len,
const double * mean,
size_t mean_len,
const double * covariance,
size_t covariance_len,
int n_dims,
double * mean_out,
double * var_out,
double * mass_out )

Integrate against a Lebesgue box, the uniform probability on that box, or a Gaussian.

Parameters
kindA gpr_bq_measure_kind_t value; any other value is GPR_ERR_INVALID_ARG.
lower,upperFor a box, n_dims values each; ignored for a Gaussian.
meanFor a Gaussian, n_dims values; ignored for a box.
covarianceFor a Gaussian, n_dims * n_dims row-major symmetric positive definite values; ignored for a box.
mean_out,var_out,mass_outOne double each. mass_out receives the measure mass: the volume, one, or one.
bqBayesian quadrature handle.
lower_lenLength of lower in elements.
upper_lenLength of upper in elements.
mean_lenLength of mean in elements.
covariance_lenLength of covariance in elements.
n_dimsNumber of coordinates per point; equals the handle dimension.
Returns
GPR_SUCCESS; GPR_ERR_NOT_TRAINED; GPR_ERR_INVALID_ARG (including a covariance that is not positive definite); GPR_ERR_UNSUPPORTED for a product Matern kernel under a non-diagonal covariance in more than two dimensions, where the joint mixture exceeds its node limit.

◆ gpr_bq_integrate_report_checked()

int gpr_bq_integrate_report_checked ( gpr_bq_t bq,
const double * lower,
size_t lower_len,
const double * upper,
size_t upper_len,
int n_dims,
gpr_bq_integral_report_t * report )

Integral over a box with the full decomposition of the variance.

Parameters
reportOne struct written on success.
bqBayesian quadrature handle.
lowerLower integration bounds, one per coordinate.
lower_lenLength of lower in elements.
upperUpper integration bounds, one per coordinate.
upper_lenLength of upper in elements.
n_dimsNumber of coordinates per point; equals the handle dimension.
Returns
As gpr_bq_integrate_checked.

◆ gpr_bq_integrate_uncertainty_checked()

int gpr_bq_integrate_uncertainty_checked ( gpr_bq_t bq,
int kind,
const double * lower,
size_t lower_len,
const double * upper,
size_t upper_len,
const double * mean,
size_t mean_len,
const double * covariance,
size_t covariance_len,
int n_dims,
gpr_bq_uncertainty_t * report )

As gpr_bq_integrate_measure_checked, with the uncertainty split by source. Same measure arguments and failures.

Parameters
reportOne struct written on success.
bqBayesian quadrature handle.
kindIntegration measure, a gpr_bq_measure_kind_t value.
lowerLower integration bounds, one per coordinate.
lower_lenLength of lower in elements.
upperUpper integration bounds, one per coordinate.
upper_lenLength of upper in elements.
meanGaussian mean, one value per coordinate; ignored for a box.
mean_lenLength of mean in elements.
covarianceRow-major Gaussian covariance; ignored for a box.
covariance_lenLength of covariance in elements.
n_dimsNumber of coordinates per point; equals the handle dimension.

◆ gpr_bq_kernel_double_integral_checked()

int gpr_bq_kernel_double_integral_checked ( gpr_bq_t bq,
const double * lower,
size_t lower_len,
const double * upper,
size_t upper_len,
int n_dims,
double * omega_out )

Kernel double integral of k over the box, written to *omega_out (output unit squared times volume squared). Same readiness rule as gpr_bq_kernel_mean_checked.

◆ gpr_bq_kernel_mean_checked()

int gpr_bq_kernel_mean_checked ( gpr_bq_t bq,
const double * lower,
size_t lower_len,
const double * upper,
size_t upper_len,
const double * X,
size_t X_len,
int n_points,
int n_dims,
double * z_out,
size_t z_len )

Kernel mean z_i = integral over the box [lower, upper] of k(x, X_i) dx, at the training points or at explicit points.

Parameters
Xn_points * n_dims row-major points (X_len doubles), or NULL with X_len 0 to use the stored training points (n_points must then equal gpr_bq_n_observations()).
z_outn_points doubles (z_len).
bqBayesian quadrature handle.
lowerLower integration bounds, one per coordinate.
lower_lenLength of lower in elements.
upperUpper integration bounds, one per coordinate.
upper_lenLength of upper in elements.
X_lenLength of X in elements.
n_pointsNumber of points at which to evaluate the kernel mean.
n_dimsNumber of coordinates per point; equals the handle dimension.
z_lenLength of z_out in elements.
Returns
GPR_SUCCESS; GPR_ERR_NOT_TRAINED when the model has neither observations nor positive configured hyperparameters; GPR_ERR_INVALID_ARG.

◆ gpr_bq_n_lengthscales()

int gpr_bq_n_lengthscales ( gpr_bq_t bq)

Number of length scales: dimension when the configuration is ARD, otherwise 1; 0 for NULL or a dead handle.

◆ gpr_bq_n_observations()

int gpr_bq_n_observations ( gpr_bq_t bq)

Number of stored observations; 0 for NULL or a dead handle.

◆ gpr_bq_predict_batch_checked()

int gpr_bq_predict_batch_checked ( gpr_bq_t bq,
const double * X_queries,
size_t X_len,
double * mean_out,
size_t mean_len,
double * var_out,
size_t var_len,
int n_queries,
int n_dims )

Posterior mean and variance at n_queries points.

Parameters
X_queriesn_queries * n_dims row-major (X_len doubles).
mean_outn_queries doubles (mean_len).
var_outn_queries doubles (var_len), or NULL with var_len 0 to skip the variance. Variances are of the latent function.
bqBayesian quadrature handle.
X_lenLength of X_queries in elements.
mean_lenLength of mean_out in elements.
var_lenLength of var_out in elements.
n_queriesNumber of query points.
n_dimsNumber of coordinates per point; equals the handle dimension.
Returns
GPR_SUCCESS; GPR_ERR_NOT_TRAINED; GPR_ERR_INVALID_ARG.

◆ gpr_bq_reset()

int gpr_bq_reset ( gpr_bq_t bq,
const gpr_bq_config_t * config )

Replace the configuration and drop every observation and any stored integration box.

Parameters
configCopied; NULL selects gpr_bq_config_defaults().
bqBayesian quadrature handle.
Returns
GPR_SUCCESS; GPR_ERR_NULL_HANDLE; GPR_ERR_INVALID_ARG for an invalid configuration or GPR_ERR_UNSUPPORTED for an unsupported configuration (std::domain_error); either leaves the handle unchanged.

◆ gpr_bq_sample_cumulative_checked()

int gpr_bq_sample_cumulative_checked ( gpr_bq_t bq,
const double * lower,
size_t lower_len,
const double * upper_limits,
size_t upper_limits_len,
int n_limits,
int n_dims,
int n_draws,
uint64_t seed,
double * draws_out,
size_t draws_len )

Draw n_draws joint samples of the cumulative integrals, deterministic in seed.

Parameters
draws_outn_draws * n_limits row-major (draws_len doubles).
bqBayesian quadrature handle.
lowerLower integration bounds, one per coordinate.
lower_lenLength of lower in elements.
upper_limitsRow-major array of nested upper bounds, one row per limit.
upper_limits_lenLength of upper_limits in elements.
n_limitsNumber of nested upper limits.
n_dimsNumber of coordinates per point; equals the handle dimension.
n_drawsNumber of joint posterior draws.
seedSeed for the reproducible random stream.
draws_lenLength of draws_out in elements.
Returns
As gpr_bq_integrate_cumulative_checked; GPR_ERR_INVALID_ARG for a non-positive n_draws.

◆ gpr_bq_select_batch_candidates_checked()

int gpr_bq_select_batch_candidates_checked ( gpr_bq_t bq,
const double * lower,
size_t lower_len,
const double * upper,
size_t upper_len,
const double * X_candidates,
size_t X_cand_len,
const double * cand_noise_var,
size_t cand_noise_len,
int n_candidates,
int n_dims,
int batch_size,
int * selected_indices_out,
size_t selected_indices_len,
double * step_reductions_out,
size_t step_reductions_len )

Greedily choose batch_size candidates, each conditioned on the ones chosen before it.

Parameters
selected_indices_outbatch_size candidate indices.
step_reductions_outbatch_size variance reductions, one per step.
bqBayesian quadrature handle.
lowerLower integration bounds, one per coordinate.
lower_lenLength of lower in elements.
upperUpper integration bounds, one per coordinate.
upper_lenLength of upper in elements.
X_candidatesRow-major candidate coordinates, one row per candidate.
X_cand_lenLength of X_candidates in elements.
cand_noise_varCandidate variances; NULL with length zero uses the configured noise.
cand_noise_lenLength of cand_noise_var in elements.
n_candidatesNumber of candidate points.
n_dimsNumber of coordinates per point; equals the handle dimension.
batch_sizeNumber of candidates to choose, at most n_candidates.
selected_indices_lenLength of selected_indices_out in elements.
step_reductions_lenLength of step_reductions_out in elements.
Returns
GPR_ERR_NOT_TRAINED before a train; GPR_ERR_INVALID_ARG unless 0 < batch_size <= n_candidates; GPR_ERR_INTERNAL for another selection exception.

◆ gpr_bq_set_basis()

int gpr_bq_set_basis ( gpr_bq_t bq,
int basis )

Select the Bayes-Sard mean model with a gpr_bq_basis_t value; GPR_BQ_BASIS_FOLLOW_CONFIG (-1) follows the configuration (use_prior_mean: constant when set, none otherwise). A trained model is rebuilt with the new basis.

Returns
GPR_ERR_INVALID_ARG for another value, or when the observations cannot determine the basis; GPR_ERR_CHOLESKY or GPR_ERR_OPTIMIZER when rebuilding a trained model fails (the model is unchanged).

◆ gpr_bq_set_extra_sigma2()

int gpr_bq_set_extra_sigma2 ( gpr_bq_t bq,
double value )

Set the extra observation-noise variance. A trained model is refit with its configured hyperparameter treatment.

Returns
GPR_ERR_INVALID_ARG unless value is non-negative and finite; another negative status when the refit fails, such as GPR_ERR_CHOLESKY for a covariance that no longer factors. A failed call leaves the stored value and the posterior unchanged.

◆ gpr_bq_set_lengthscales_checked()

int gpr_bq_set_lengthscales_checked ( gpr_bq_t bq,
const double * values,
size_t values_len )

Pin the length scales. A trained model is rebuilt with them held and the signal variance kept at its current value; the observations and the configured hyperparameter treatment stay unchanged.

Parameters
valuesgpr_bq_n_lengthscales() positive finite doubles (values_len doubles).
bqBayesian quadrature handle.
values_lenLength of values in elements.
Returns
GPR_SUCCESS; GPR_ERR_INVALID_ARG for a wrong count or a value that is not positive and finite; another negative status when the rebuild fails. A failed call leaves the model unchanged.

◆ gpr_bq_set_magn_sigma2()

int gpr_bq_set_magn_sigma2 ( gpr_bq_t bq,
double value )

Pin the signal variance. A trained model is rebuilt with it held and the length scales kept (an ARD set stays anisotropic); the configured hyperparameter treatment stays unchanged.

Returns
GPR_ERR_INVALID_ARG unless value is positive and finite; another negative status when the rebuild fails (the model is unchanged).

◆ gpr_bq_train_bounded_checked()

int gpr_bq_train_bounded_checked ( gpr_bq_t bq,
const double * X,
size_t X_len,
const double * y,
size_t y_len,
const double * noise_var,
size_t noise_var_len,
const double * lower,
size_t lower_len,
const double * upper,
size_t upper_len,
int n_obs,
int n_dims )

Train and store an explicit integration box. Each lower[d] is finite and strictly below upper[d], and every training coordinate lies in the closed interval. Null noise_var with a zero length stores zero noise, as gpr_bq_train_checked does. The box is kept for later refits and for appended rows.

Parameters
lower,uppern_dims values each (lower_len, upper_len doubles).
bqBayesian quadrature handle.
XRow-major training coordinates, one row per observation.
X_lenLength of X in elements.
yValues at the training coordinates.
y_lenLength of y in elements.
noise_varObservation variances, or NULL with length zero for zero noise.
noise_var_lenLength of noise_var in elements.
lower_lenLength of lower in elements.
upper_lenLength of upper in elements.
n_obsNumber of training observations.
n_dimsNumber of coordinates per point; equals the handle dimension.
Returns
As gpr_bq_train_checked. A short buffer, a non-finite value, or a point outside the box returns GPR_ERR_INVALID_ARG and leaves the model unchanged. A null handle returns GPR_ERR_NULL_HANDLE.

◆ gpr_bq_train_checked()

int gpr_bq_train_checked ( gpr_bq_t bq,
const double * X,
size_t X_len,
const double * y,
size_t y_len,
const double * noise_var,
size_t noise_var_len,
int n_obs,
int n_dims )

Train on n_obs points and infer the integration box from the training extrema.

Parameters
Xn_obs * n_dims row-major coordinates (X_len doubles).
yn_obs values (y_len doubles).
noise_varn_obs non-negative observation variances, or NULL with noise_var_len 0 for zero noise.
n_dimsMust equal gpr_bq_dimension().
bqBayesian quadrature handle.
X_lenLength of X in elements.
y_lenLength of y in elements.
noise_var_lenLength of noise_var in elements.
n_obsNumber of training observations.
Returns
GPR_SUCCESS; GPR_ERR_INVALID_ARG for a short buffer, a non-finite value, a negative variance or a dimension mismatch; GPR_ERR_CHOLESKY when the covariance cannot be factored; GPR_ERR_OPTIMIZER when hyperparameter inference fails. A failed call leaves the model unchanged.