Gramacy (2007) Sine Function

Gramacy (2007) Sine Function#

import numpy as np
import matplotlib.pyplot as plt
import uqtestfuns as uqtf

The Gramacy (2007) sine function (or GramacySine function for short) is a one-dimensional, scalar-valued function that features two regimes: one part is a mixture of sines and cosines, and another part is a linear function. The function was introduced in [Gra07] in the context of metamodeling with non-stationary Gaussian processes.

A plot of the function is shown below for \(x \in [0, 20]\).

../_images/4b599a86ab71dfea8b7b639a207a263424e90dc1166a22289e54b01a61142a62.png

Note that the function is discontinuous at \(x = 9.6%\) which also pinpoints the change of regime.

Note

In the original paper, the response of the function is disturbed by an independent identically distributed (i.i.d) Gaussian noise \(\varepsilon \sim \mathcal{N}(0, \sigma_n=0.1)\). The training data is generated from 100 equispaced points in \([0., 20.]\); these points are shown in the above plot.

Test function instance#

To create a default instance of the test function:

my_testfun = uqtf.GramacySine()

Check if it has been correctly instantiated:

print(my_testfun)
Function ID      : GramacySine
Input Dimension  : 1 (fixed)
Output Dimension : 1
Parameterized    : False
Description      : One-dimensional sine function from Gramacy (2007)
Applications     : metamodeling

Description#

The test function is analytically defined as follows[1]:

\[\begin{split} \mathcal{M}(x) = \begin{cases} \sin{(\frac{\pi x}{5})} + \frac{1}{5} \cos{(\frac{4 \pi x}{5})}, & x \leq 9.6 \\ \frac{1}{10} x - 1, & x > 9.6, \end{cases} \end{split}\]

where \(x\) is defined below.

Probabilistic input#

Based on [Gra07], the domain of the function is \([0, 20]\). This input can be modeled with a single uniform random variable shown below.

Hide code cell source
print(my_testfun.prob_input)
Function ID     : Gramacy1DSine
Input ID        : Gramacy2007
Input Dimension : 1
Description     : Input model for the one-dimensional function from Gramacy
                  (2007)
Marginals       :

 No.    Name    Distribution    Parameters    Description
-----  ------  --------------  ------------  -------------
  1      x        uniform       [ 0. 20.]          -

References#

[Gra07] (1,2,3)

Robert B. Gramacy. tgp: an R package for Bayesian nonstationary, semiparametric nonlinear regression and design by Treed Gaussian Process models. Journal of Statistical Software, 2007. doi:10.18637/jss.v019.i09.