# Cross covariance. cross_cov = UniformMixing(gamma0=0.4, sigmas=[np.sqrt(1.0), np.sqrt(5.5)]) covariance = FactorCovariance(matern_cov, cross_cov, n_out=n_out) # Specify mean function mean = ConstantMean([0.0, 5.0]) # Create the GRF. myGRF = GRF(mean, covariance) # Create an equilateral triangular grid in 2 dims. # Number of respones. my_grid = TriangularGrid(40) my_square_grid = SquareGrid(50, 2) my_discrete_grf = DiscreteGRF.from_model(myGRF, my_grid) # Sample and plot. sample = my_discrete_grf.sample() plot_grid_values(my_grid, sample) # Sample and plot. sample = my_discrete_grf.sample() plot_grid_values(my_grid, sample) # Sample the continuous version and compare. sample_cont = myGRF.sample_isotopic(my_grid.points) plot_grid_values(my_grid, sample_cont)
# Cross covariance. cross_cov = UniformMixing(gamma0=0.9, sigmas=[np.sqrt(0.25), np.sqrt(0.6)]) covariance = FactorCovariance(matern_cov, cross_cov, n_out=n_out) # Specify mean function mean = ConstantMean([1.0, 0]) # Create the GRF. myGRF = GRF(mean, covariance) # Create a regular square grid in 2 dims. # Number of repsones. dim = 2 my_grid = SquareGrid(100, dim) # Observe some data. S_y = torch.tensor([[0.2, 0.1], [0.2, 0.2], [0.2, 0.3], [0.2, 0.4], [0.2, 0.5], [0.2, 0.6], [0.2, 0.7], [0.2, 0.8], [0.2, 0.9], [0.2, 1.0], [0.6, 0.5]]) L_y = torch.tensor([0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0]) y = torch.tensor(11 * [-6]) mu_cond_grid, mu_cond_list, mu_cond_iso, K_cond_list, K_cond_iso = myGRF.krig_grid( my_grid, S_y, L_y, y, noise_std=0.05, compute_post_cov=True) # Plot. from meslas.plotting import plot_2d_slice, plot_krig_slice plot_krig_slice(mu_cond_grid, S_y, L_y)