GaussianProcess

GaussianProcess

A Gaussian process that can be used to make predictions based on its training data.

Internal state (mirrors the Rust GaussianProcess struct, mod.rs:59):

  • prior Prior instance.
  • kernel Kernel instance.
  • noise number — noise STANDARD DEVIATION (not variance).
  • choleskyEpsilon number | null — substitute pivot for Cholesky (or null).
  • trainingInputs ExtendableMatrix.
  • trainingOutputs ExtendableVector — stores outputs − prior(inputs) (the residual!).
  • covmatCholesky CholeskyDecomposition of K = kernel(X,X) + noise²·I.

Constructor

new GaussianProcess(prior, kernel, noise, choleskyEpsilon, trainingInputs, trainingOutputs)

Description:
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

GaussianProcess

Members

choleskyEpsilon :number|null

Source:
Type:
  • number | null

covmatCholesky

Source:

kernel :object

Source:
Type:
  • object

noise :number

Description:
  • noise standard deviation

Source:

noise standard deviation

Type:
  • number

prior :object

Source:
Type:
  • object

trainingInputs :ExtendableMatrix

Source:
Type:

trainingOutputs :ExtendableVector

Source:
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 maxIter iterations, stopping early when all gradients are below convergenceFraction·param or after maxTime.

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 output is 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 a DMatrix).

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 calling predict and predict_variance separately.

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 where rng is a () => number ∈ [0,1) (e.g. from mulberry32).

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:
Type
GaussianProcessBuilder

(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: default is 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:
Source:
Parameters:
Name Type Description
inputs Array.<number> | Array.<Array.<number>>
outputs number | Array.<number>
Returns:
Type
GaussianProcess