Skip to content

Metamodels

Linear Basis Function Models

Linear basis function models are a simple class of metamodels that express the predicted output as a linear combination of basis functions evaluated for the input variables defined as

y(x)=i=1nβiφi(x),

where φi(x) are nonlinear basis functions that map the input space into an intermediate feature space and β represents the adjustable weights. Some commonly used basis functions are introduced next.

Monomial Basis

Monomial basis functions are defined as the powers, or products of powers in the multivariate case, of the input variables with a total degree of less than or equal to d. For example, the monomial basis in two variables of degree d=3 in graded reverse lexicographic order is given by

φ(x)=[1,x2,x1,x22,x1x2,x12,x23,x1x22,x12x2,x13]

The construction of this MonomialBasis is presented next.

julia
φ = MonomialBasis(2, 3)
MonomialBasis(2, 3, Monomials.Monomial[1, x2, x1, x2², x1x2, x1², x2³, x1x2², x1²x2, x1³])

By default the MonomialBasis includes the constant (zero degree) term. This behaviour can be changed by passing the include_zero=false keyword.

Radial Basis

A radial basis function (RBF) is a real-valued function φ(||xc||) that depends on the distance between the input x and a fixed point c, called a center. These functions are multivariate but reduce to scalar functions of the radius r=||xc||, hence the name radial basis function. The distance used is most commonly the euclidian norm. UncertaintyQuantification provides two types of RBFs.

Gaussian

φ(r)=exp(ϵr)

here, ϵ is a shape parameter. Gaussian radial basis functions are exposed through the GaussianRadialBasis struct.

Polyharmonic

φ(r)={rkwithk=1,3,5,,rkln(r)withk=2,4,6,

Note, that polyharmonic radial basis functions do not require a shape parameter. These RBs can be constructed using the PolyharmonicRadialBasis type.

Least Squares

Despite the nonlinearity of the basis functions, the model remains linear in its parameters, which allows efficient estimation of the weights using ordinary least squares. Given m observations (xi,yi), for i=1,,m we construct the design matrix Φ where each row contains the evaluated basis functions for one input:

Φij=φj(xi), for i=1,,n and j=1,,m

The optimal weight vector is found by minimizing the sum-of-squares error

E(β)=i=1m(y(xi,β)yi)2

yielding the closed-form solution via

β=(ΦΦ)1Φy,

where y is the output vector.

Example

Consider the function

y(x)=xcos(x),

where xU(5,5)

We use HaltonSampling to sample 150 data points from the input variable, evaluate the model, and fit a LinearBasisFunctionModel using a MonomialBasis of degree d=9.

julia
x = RandomVariable(Uniform(-5, 5), :x)
y = Model(
        df -> df.x .* cos.(df.x),
        :y,
    )
data = sample(x, HaltonSampling(150))
evaluate!(y, data)
lbfm = LinearBasisFunctionModel(data, :y, MonomialBasis(1, 9))
ResponseSurface(MonomialBasis(1, 9, Monomials.Monomial[1, x1, x1², x1³, x1⁴, x1⁵, x1⁶, x1⁷, x1⁸, x1⁹]), [0.00018241593646902075, 0.9878644609495059, -0.00018150970456987044, -0.48925985169682223, 4.747249404303626e-5, 0.038987490233917725, -3.913393749589379e-6, -0.0011115728398402001, 9.668870671278248e-8, 1.1603496934147144e-5], [:x], :y)

A plot comparing the resulting model to the data points is presented next.

Response Surface

A linear basis function model constructed from a MonomialBasis is also known as a polynomial Response Surface [31]. For this reason we provide a convenient alias ResponseSurface. Using this alias the previous example can be adapted as follows.

julia
rs = ResponseSurface(data, :y, 9)
ResponseSurface(MonomialBasis(1, 9, Monomials.Monomial[1, x1, x1², x1³, x1⁴, x1⁵, x1⁶, x1⁷, x1⁸, x1⁹]), [0.00018241593646902075, 0.9878644609495059, -0.00018150970456987044, -0.48925985169682223, 4.747249404303626e-5, 0.038987490233917725, -3.913393749589379e-6, -0.0011115728398402001, 9.668870671278248e-8, 1.1603496934147144e-5], [:x], :y)

Design Of Experiments

Several experimental designs have been developed to efficiently estimate ResponseSurface models [31]. Although designed for response surface methodology these designs can be used to fit any metamodel. However, for more complex models we suggest using Quasi Monte Carlo sampling schemes instead.

The designs implemented in UncertaintyQuantification are TwoLevelFactorial, FullFactorial, FractionalFactorial, CentralComposite, BoxBehnken, and PlackettBurman.

Interval Predictor Model

An interval predictor model (IPM)[32] is a function that returns an interval instead of a precise value for the dependent variable given as

Iy(x,P)={y=pTφ(x),pP},

where φ(x) is an arbitrary basis and the uncertainty set P is defined as

P={p:ppp}.

Using the defining vertices of P p and p the IPM results as

Iy(x,P)=[y(x,p,p),y(x,p,p)],

with

y(x,p,p)=pT(φ(x)|φ(x)|2)+pT(φ(x)+|φ(x)|2)

and

y(x,p,p)=pT(φ(x)+|φ(x)|2)+pT(φ(x)|φ(x)|2).

Here, y and y are the lower and upper bounds of the IPM.

The distance between the lower and upper bound given by

δy(x,p,p)=(pp)T|φ(x)|

is known as the spread of the IPM. The optimal defining vertices for a given data set are found by minimizing the average spread such that all data points fall into the IPM by solving the following convex constrained optimization problem.

{p,p}=argmaxu,v{Ex[δy(x,u,v]:y(xi,v,u)yiy(xi,v,u),uv}

Example

Consider the function

y(x)=x2cos(x)sin(3x)exp(x2)xcos(x2)+xg,

where xU(5.5,5.5 and gN(0,1). We generate a data sequence of N=150 points and fit an IntervalPredictorModel using a MonomialBasis of sixth degree.

julia
x = RandomVariable(Uniform(-5.5, 5.5), :x)
data = sample(x, HaltonSampling(150))

m = Model(
        df ->
            df.x .^ 2 .* cos.(df.x) .- sin.(3 * df.x) .* exp.(-df.x .^ 2) .- df.x .-
            cos.(df.x .^ 2) .+ df.x .* randn(size(df, 1)),
        :y,
    )

evaluate!(m, data)

b = MonomialBasis(1,6)
ipm = IntervalPredictorModel(data, :y, b)
IntervalPredictorModel{MonomialBasis}(MonomialBasis(1, 6, Monomials.Monomial[1, x1, x1², x1³, x1⁴, x1⁵, x1⁶]), [-1.917225644166731, -1.7765048387513835, -0.9899778933490903, 0.05447606704122796, -0.04630799524392712, -0.001956415232260404, 0.003457335796681521], [6.970384634890219, -0.8018186415622978, -0.9899778933489536, 0.05447606704123612, -0.04630799524392633, -0.001956415232260114, 0.0037807639963089814], [:x], :y, 150)

The following figure presents the bounds of the resulting IPM and the corresponding least squares solution. Note, that the least squares solution is not guaranteed to be between the bounds of the IPM.

IPM reliability

The reliability of the IPM, that is the probability that and unobserved data point (x,y) will fall in the interval Iy(x,P) can be assessed using the reliability function. The function reliability(ipm, ϵ) returns the confidence parameter β. Then, the reliability of the IPM is no less than 1ϵ with confidence 1β.

julia
1 - reliability(ipm, 0.1548)
0.9898502075787752

Reliability analysis

As the IPM is an imprecise model, it can only be applied in a reliability analysis using the DoubleLoop or RandomSlicing. For more information, see Imprecise Reliability Analysis.