Skip to content

Use Cases

Common application scenarios for gp4c.

1. Standard GP Regression

Observe f at sparse points, predict at dense points:

from gp4c import sample_posterior, Observations, SamplingSpec

obs = Observations(x_f=x_train, y_f=y_train, noise_f=0.01)
spec = SamplingSpec(x_f=x_test)
result = sample_posterior(obs, spec, ell=1.0, n_samples=10)

Applications: Function interpolation, time series prediction, spatial modeling.

2. Derivative Prediction

Train on f, predict the derivative h:

obs = Observations(x_f=x_train, y_f=y_train, noise_f=0.01)
spec = SamplingSpec(x_h=x_test)
result = sample_posterior(obs, spec, ell=1.0, n_samples=10)
# result.h_mean contains predicted derivative

Applications: Sensitivity analysis, gradient-based optimization, physics modeling.

3. Inverse Problem: Recover f from Derivatives

Observe derivatives, infer the function:

obs = Observations(x_h=x_deriv, y_h=y_deriv, noise_h=0.01)
spec = SamplingSpec(x_f=x_dense)
result = sample_posterior(obs, spec, ell=1.0, n_samples=10)

Applications: Reconstructing trajectories from velocity data, inferring potentials from forces.

4. Gradient-Enhanced GP

Use both function and derivative observations:

obs = Observations(
    x_f=x_func, y_f=y_func, noise_f=0.01,
    x_h=x_deriv, y_h=y_deriv, noise_h=0.02
)
spec = SamplingSpec(x_f=x_test)
result = sample_posterior(obs, spec, ell=1.0, n_samples=10)

Applications: Surrogate modeling with gradient information, Bayesian optimization with derivatives.

5. Integral Constraints

Know the integral, infer the function:

obs = Observations(x_g=x_integral, y_g=y_integral, noise_g=0.01)
spec = SamplingSpec(x_f=x_dense)
result = sample_posterior(obs, spec, ell=1.0, n_samples=10)

Applications: Mass balance constraints, cumulative distribution reconstruction, conservation laws.

6. Multi-Fidelity Modeling

Combine sparse high-fidelity observations with dense low-fidelity data:

# High-fidelity function observations
x_hf = np.array([1.0, 3.0, 5.0])
y_hf = expensive_simulation(x_hf)

# Low-fidelity derivative observations
x_lf = np.linspace(0, 6, 20)
y_lf = cheap_derivative_estimate(x_lf)

obs = Observations(
    x_f=x_hf, y_f=y_hf, noise_f=0.001,
    x_h=x_lf, y_h=y_lf, noise_h=0.1
)
spec = SamplingSpec(x_f=x_dense)
result = sample_posterior(obs, spec, ell=1.0, n_samples=10)

Applications: Scientific computing, engineering design optimization.

7. Physics-Informed Regression

Enforce derivative relationships through observations:

# Observe position
obs_position = Observations(x_f=t_obs, y_f=position, noise_f=0.01)

# Enforce velocity constraint
obs_velocity = Observations(x_h=t_constraint, y_h=velocity, noise_h=0.05)

obs = Observations(
    x_f=obs_position.x_f, y_f=obs_position.y_f,
    x_h=obs_velocity.x_h, y_h=obs_velocity.y_h,
    noise_f=0.01, noise_h=0.05
)
spec = SamplingSpec(x_f=t_dense, x_h=t_dense)
result = sample_posterior(obs, spec, ell=1.0, n_samples=10)

Applications: ODE/PDE constraints, physical consistency in machine learning.

Next Steps