smt icon indicating copy to clipboard operation
smt copied to clipboard

Question on drawing drawing sample from MFK GP posterior.

Open jtneedels opened this issue 1 year ago • 3 comments

Hi,

I'd like to be able to draw a sample from my MFK GP posterior - that is a multivariate Gaussian based on the the posterior mean and covariance. I don't see a method to generate a sample in the code (just want to check if I am missing it). Otherwise, is there a way to output the full posterior covariance matrix, rather than just the variance, so that I can generate my own samples?

Thanks so much for the help!

jtneedels avatar Nov 16 '23 01:11 jtneedels

Hi,

You're right, currently there is no API for sampling MFK GPs or accessing covariance matrices directly. If you want to implement such methods take a look at krg_sampling.py where sampling for kriging is implemented. You could mix and match the code with the one of MFK to get what you want... And then feel free to contribute with a PR :wink:

relf avatar Nov 16 '23 09:11 relf

Yes, you can sample and generate the covariance matrix within SMT. Everything is included in the utils folder:

  • from smt.utils.krg_sampling import sample_trajectory, gauss_legendre_grid, rectangular_grid, simpson_grid, eig_grid, sample_eigen There is a tutorial describing how to sample from a GP within SMT: https://github.com/SMTorg/smt/blob/master/tutorial/SMT_GP_Sampling.ipynb

Paul-Saves avatar Nov 16 '23 10:11 Paul-Saves

Great, thank you both so much! I'll take a look at this code and tutorial.

jtneedels avatar Nov 16 '23 17:11 jtneedels