Skip to content
Snippets Groups Projects
Commit 4324e179 authored by Hu Zhao's avatar Hu Zhao
Browse files

docs: refine example plots, correct typos

parent 678f11e1
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ScalarGaSP: GP emulation for a single-output function ...@@ -6,7 +6,7 @@ ScalarGaSP: GP emulation for a single-output function
# %% md # %% md
# #
# This example shows how apply Gaussian process emulation to a single-output # This example shows how to apply Gaussian process emulation to a single-output
# function using class :class:`.ScalarGaSP`. # function using class :class:`.ScalarGaSP`.
# #
# The task is to build a GP emulator for the function :math:`y = x * sin(x)` # The task is to build a GP emulator for the function :math:`y = x * sin(x)`
...@@ -54,7 +54,7 @@ validation = emulator.loo_validate() ...@@ -54,7 +54,7 @@ validation = emulator.loo_validate()
# %% md # %% md
# #
# Let's plot emulator predictions vs actual outputs. The error bar indicates the # Let's plot emulator predictions vs actual outputs. The error bar indicates the
# 95% credible interval. # standard deviation.
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
...@@ -66,7 +66,8 @@ ax.set_xlim(np.min(y)-1,np.max(y)+1) ...@@ -66,7 +66,8 @@ ax.set_xlim(np.min(y)-1,np.max(y)+1)
ax.set_ylim(np.min(y)-1,np.max(y)+1) ax.set_ylim(np.min(y)-1,np.max(y)+1)
_ = ax.plot([np.min(y)-1,np.max(y)+1], [np.min(y)-1,np.max(y)+1]) _ = ax.plot([np.min(y)-1,np.max(y)+1], [np.min(y)-1,np.max(y)+1])
_ = ax.errorbar(y, validation[:,0], validation[:,1], fmt='.', linestyle='') _ = ax.errorbar(y, validation[:,0], validation[:,1], fmt='.', linestyle='', label='prediction and std')
_ = plt.legend()
# %% md # %% md
...@@ -81,7 +82,8 @@ testing_input = np.arange(0,10,0.1) ...@@ -81,7 +82,8 @@ testing_input = np.arange(0,10,0.1)
predictions = emulator.predict(testing_input) predictions = emulator.predict(testing_input)
plt.plot(testing_input, predictions[:, 0], 'r-', label= "mean") plt.plot(testing_input, predictions[:, 0], 'r-', label= "mean")
plt.scatter(x, y, s=15, c='k', label="training data", zorder=2) plt.scatter(x, y, s=15, c='k', label="training data", zorder=3)
plt.plot(testing_input, f(testing_input), 'k:', zorder=2, label="true function")
plt.fill_between(testing_input, predictions[:, 1], predictions[:, 2], alpha=0.3, label="95% CI") plt.fill_between(testing_input, predictions[:, 1], predictions[:, 2], alpha=0.3, label="95% CI")
plt.xlabel('x') plt.xlabel('x')
plt.ylabel('emulator-predicted y') plt.ylabel('emulator-predicted y')
...@@ -100,6 +102,7 @@ for i in range(nsamples): ...@@ -100,6 +102,7 @@ for i in range(nsamples):
plt.plot(testing_input, samples[:,i], '--', label=f'sample{i+1}') plt.plot(testing_input, samples[:,i], '--', label=f'sample{i+1}')
plt.scatter(x, y, s=15, c='k', label="training data", zorder=2) plt.scatter(x, y, s=15, c='k', label="training data", zorder=2)
plt.plot(testing_input, f(testing_input), 'k:', zorder=2, label="true function")
plt.fill_between(testing_input, predictions[:, 1], predictions[:, 2], alpha=0.3, label="95% CI") plt.fill_between(testing_input, predictions[:, 1], predictions[:, 2], alpha=0.3, label="95% CI")
plt.xlabel('x') plt.xlabel('x')
plt.ylabel('emulator-predicted y') plt.ylabel('emulator-predicted y')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment