Constructor
new GaussianProcess(prior, kernel, noise, choleskyEpsilon, trainingInputs, trainingOutputs)
- Description:
Raw constructor (
mod.rs:142). Prefer GaussianProcess.default or GaussianProcess.builder.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
prior |
object | Prior instance. |
kernel |
object | Kernel instance. |
noise |
number | noise standard deviation (≥ 0). |
choleskyEpsilon |
number | null | substitute pivot (or null to throw on failure). |
trainingInputs |
Array.<number> | Array.<Array.<number>> | raw inputs. |
trainingOutputs |
number | Array.<number> | raw outputs (NOT yet residualised). |
Classes
Members
choleskyEpsilon :number|null
Type:
- number | null
covmatCholesky
kernel :object
Type:
- object
noise :number
- Description:
noise standard deviation
- Source:
noise standard deviation
Type:
- number
prior :object
Type:
- object
trainingInputs :ExtendableMatrix
Type:
trainingOutputs :ExtendableVector
Type:
Methods
add_samples(inputs, outputs)
- Description:
Adds new samples to the model (
mod.rs:173).Updates the model in O(n²) (faster than retraining from scratch) but does NOT refit the parameters.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<number> | Array.<Array.<number>> | |
outputs |
number | Array.<number> |
fit_parameters(fitPrior, fitKernel, maxIter, convergenceFraction, maxTimeopt)
- Description:
Fits the requested parameters and retrains the model (
mod.rs:406).Noise and kernel parameters are fitted by gradient ascent (ADAM) on the marginal log-likelihood. Runs for at most
maxIteriterations, stopping early when all gradients are belowconvergenceFraction·param or aftermaxTime.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
fitPrior |
boolean | fit the prior to the data. |
||
fitKernel |
boolean | fit the kernel (and noise) parameters. |
||
maxIter |
number | max gradient-ascent iterations. |
||
convergenceFraction |
number | relative convergence threshold. |
||
maxTime |
number |
<optional> |
3600000
|
max fitting time in MILLISECONDS (Rust uses chrono::Duration seconds). |
likelihood() → {number}
- Description:
Log likelihood of the current model given the training data (
mod.rs:196).Formula: −½ ( outputᵀ·K⁻¹·output + Σ_r ln|kernel(xᵣ,xᵣ) + noise²| + n·ln(2π) )
where
outputis the prior residual.
- Source:
Returns:
- Type
- number
predict(inputs) → {number|Array.<number>}
- Description:
Predicts the mean of the Gaussian process for each row of
inputs(mod.rs:226).Formula:
prior + cov(input,train)·K⁻¹·output.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<number> | Array.<Array.<number>> |
Returns:
number for a single-point input, number[] otherwise.
- Type
- number | Array.<number>
predict_covariance(inputs) → {Array.<Array.<number>>}
- Description:
Returns the full covariance matrix for the rows of
inputs(mod.rs:329).Formula: cov(input,input) − cov(input,train)·K⁻¹·cov(train,input)
ALWAYS returns a
number[][]matrix (never scalarised — matches Rust which always returns aDMatrix).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<number> | Array.<Array.<number>> |
Returns:
(nInput × nInput)
- Type
- Array.<Array.<number>>
predict_mean_variance(inputs)
- Description:
Predicts both the mean and the variance for each row of
inputs(mod.rs:290). Faster than callingpredictandpredict_varianceseparately.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<number> | Array.<Array.<number>> |
Returns:
predict_variance(inputs) → {number|Array.<number>}
- Description:
Predicts the variance of the Gaussian process for each row of
inputs(mod.rs:248).Formula (diagonal of): cov(input,input) − cov(input,train)·K⁻¹·cov(train,input)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<number> | Array.<Array.<number>> |
Returns:
- Type
- number | Array.<number>
sample_at(inputs) → {MultivariateNormal}
- Description:
Produces a multivariate Gaussian that can be sampled at the input points (
mod.rs:371).Covariance: cov(input,input) − cov(input,train)·K⁻¹·cov(train,input) Mean: prior + cov(input,train)·K⁻¹·output
The returned MultivariateNormal has a
.sample(rng)method whererngis a() => number ∈ [0,1)(e.g. frommulberry32).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<number> | Array.<Array.<number>> |
Returns:
- Type
- MultivariateNormal
(static) builder(inputs, outputs) → {GaussianProcessBuilder}
- Description:
Returns a builder to define specific parameters of the Gaussian process (
mod.rs:129). Defaults to a Gaussian kernel + constant prior.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<number> | Array.<Array.<number>> | |
outputs |
number | Array.<number> |
Returns:
(static) default(inputs, outputs) → {GaussianProcess}
- Description:
Returns a Gaussian process with a Gaussian kernel and a constant prior, both fitted to the data (
mod.rs:96).Equivalent to
builder(inputs, outputs).fit_kernel().fit_prior().train().Note:
defaultis a valid static-method name in JS classes; see GaussianProcess.fromData for a safe alias.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<number> | Array.<Array.<number>> | |
outputs |
number | Array.<number> |
Returns:
- Type
- GaussianProcess
(static) fromData(inputs, outputs) → {GaussianProcess}
- Description:
Safe alias of GaussianProcess.default (in case a toolchain dislikes the
defaultmethod name). Identical behaviour.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<number> | Array.<Array.<number>> | |
outputs |
number | Array.<number> |
Returns:
- Type
- GaussianProcess