Skip to content

Commit

Permalink
Kriging with uppercase K
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmure committed Mar 20, 2024
1 parent 6a26828 commit c3bb32b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
# Abstract
# --------
#
# In this example, we create a kriging metamodel for a function which has
# In this example, we create a Kriging metamodel for a function which has
# scalar real inputs and outputs.
# We show how to create the learning and the validation samples.
# We show how to create the kriging metamodel by choosing a trend and a covariance model.
# Finally, we compute the predicted kriging confidence interval using the conditional variance.
# We show how to create the Kriging metamodel by choosing a trend and a covariance model.
# Finally, we compute the predicted Kriging confidence interval using the conditional variance.

# %%
# Introduction
Expand Down Expand Up @@ -40,7 +40,7 @@
# :math:`x_i` 1 3 4 6 7.9 11 11.5
# ============ === === === === ===== ==== ======
#
# We are going to consider a kriging metamodel with:
# We are going to consider a Kriging metamodel with:
#
# * a constant trend,
# * a Matern covariance model.
Expand Down Expand Up @@ -141,7 +141,7 @@ def plot_data_test(x_test, y_test):


# %%
# The following function plots the kriging data.
# The following function plots the Kriging data.


# %%
Expand All @@ -165,19 +165,19 @@ def plot_data_kriging(x_test, y_test_MM):
view = viewer.View(graph)

# %%
# We see that the kriging metamodel is interpolating. This is what is meant by *conditioning* a gaussian process.
# We see that the Kriging metamodel is interpolating. This is what is meant by *conditioning* a gaussian process.
#
# We see that, when the sine function has a strong curvature between two points which are separated by a large distance (e.g. between :math:`x=4` and :math:`x=6`),
# then the kriging metamodel is not close to the function :math:`g`.
# then the Kriging metamodel is not close to the function :math:`g`.
# However, when the training points are close (e.g. between :math:`x=11` and :math:`x=11.5`) or when the function is nearly linear (e.g. between :math:`x=8` and :math:`x=11`),
# then the kriging metamodel is quite accurate.
# then the Kriging metamodel is quite accurate.

# %%
# Compute confidence bounds
# -------------------------

# %%
# In order to assess the quality of the metamodel, we can estimate the kriging variance and compute a 95% confidence interval associated with the conditioned gaussian process.
# In order to assess the quality of the metamodel, we can estimate the Kriging variance and compute a 95% confidence interval associated with the conditioned gaussian process.
#
# We begin by defining the `alpha` variable containing the complementary of the confidence level than we want to compute.
# Then we compute the quantile of the gaussian distribution corresponding to `1-alpha/2`. Therefore, the confidence interval is:
Expand All @@ -201,10 +201,10 @@ def computeQuantileAlpha(alpha):
print("Quantile alpha=%f" % (quantileAlpha))

# %%
# In order to compute the kriging error, we can consider the conditional variance.
# In order to compute the Kriging error, we can consider the conditional variance.
# The `getConditionalCovariance` method returns the covariance matrix `covGrid`
# evaluated at each points in the given sample. Then we can use the diagonal
# coefficients in order to get the marginal conditional kriging variance.
# coefficients in order to get the marginal conditional Kriging variance.
# Since this is a variance, we use the square root in order to compute the
# standard deviation.
# However, some coefficients in the diagonal are very close to zero and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Advanced kriging
Advanced Kriging
================
"""
# %%
Expand Down Expand Up @@ -58,7 +58,7 @@
view = viewer.View(graph)

# %%
# Create the kriging algorithm
# Create the Kriging algorithm
# ----------------------------

# 1. basis
Expand All @@ -72,7 +72,7 @@
cov = ot.MaternModel([1.0], [2.5], 1.5)
print(cov)

# 3. kriging algorithm
# 3. Kriging algorithm
algokriging = ot.KrigingAlgorithm(x, y, cov, basis)

# error measure
Expand Down Expand Up @@ -127,8 +127,8 @@
graph.setLegendPosition("upper left")
View(graph, axes=[ax1])

# On the right, the conditional kriging variance
graph = ot.Graph("", "x", "Conditional kriging variance", True, "")
# On the right, the conditional Kriging variance
graph = ot.Graph("", "x", "Conditional Kriging variance", True, "")
# Sample for the data
sample = ot.Sample(n_pt, 2)
sample[:, 0] = x
Expand Down

0 comments on commit c3bb32b

Please sign in to comment.