How to use the established meta-model (such as Kriging) as Conventional Function in Matlab?

Hi @GPLai,

Referring to the title of your question, I assume you want to use the predictor part of Kriging. As you know, this prediction is made by calling uq_evalModel on a UQLab model and metamodel objects (not just Kriging).

So the easiest way to directly call this predictor as a MATLAB function is by using an anonymous function to wrap the call to uq_evalModel. Let’s suppose you already have a Kriging metamodel object myKriging, then you can write:

myKrigingPredictor = @(X) uq_evalModel(myKriging,X);

Then you can pass this function handle to your optimization function.

However, if you want to get the Kriging variance, which is the second output, for an optimization purpose, I think you might need to use a MATLAB normal function to wrap things first before passing the function handle to an optimization function. For instance, such a function can be:

function krigingVar = getKrigingVar(KrigingObj,X)
[~,krigingVar] = uq_evalModel(KrigingObj,X)
end

and then use an anonymous function to bring a particular Kriging object (say, myKriging) into the function: krigingVar = @(X) getKrigingVar(myKriging,X) before passing the handle to an optimization function.

BTW, There was once a question similar to yours here:

UQLab does not have a built-in support for such a refinement scheme to create a metamodel, although a similar scheme is used specifically in the context of reliability analysis. I think your approach makes sense. In any case, we’ll sure be glad to hear about your experience on whether you manage to improve the metamodel :wink:.

Hope this helps!

PS: Your question would be more fitting to be in the UQLab Community Q&A, and not in the general forum section. So I took the liberty of moving it there :smiley: .