McLain S4 Function#

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

The McLain S4 function is a two-dimensional scalar-valued function. The function was introduced in [McL74] as a test function for procedures to construct contours from a given set of points.

Note

The McLain’s test functions are a set of five two-dimensional functions that mathematically defines surfaces. The functions are:

  • S1: A part of a sphere

  • S2: A steep hill rising from a plain

  • S3: A less steep hill

  • S4: A long narrow hill (this function)

  • S5: A plateau and plain separated by a steep cliff

../_images/9903e37d66c21dc927a1cf57c3a3178b990aefb05071ed58c9a760545fa5ed94.png

As shown in the plots above, the resulting surface consists of a long narrow hill running diagonally from \((0.0, 10.0)\) to \((10.0, 0.0)\). The maximum height is \(1.0\) at \((5.5, 5.5)\).

Test function instance#

To create a default instance of the McLain S4 function:

my_testfun = uqtf.McLainS4()

Check if it has been correctly instantiated:

print(my_testfun)
Function ID      : McLainS4
Input Dimension  : 2 (fixed)
Output Dimension : 1
Parameterized    : False
Description      : McLain S4 function from McLain (1974)
Applications     : metamodeling

Description#

The McLain S4 function is defined as follows:

\[ \mathcal{M}(\boldsymbol{x}) = \exp{\left[ -1 \left( (x_1 + x_2 - 11)^2 + \frac{(x_1 - x_2)^2}{10} \right) \right]} \]

where \(\boldsymbol{x} = \{ x_1, x_2 \}\) is the two-dimensional vector of input variables further defined below.

Probabilistic input#

Based on [McL74], the probabilistic input model for the function consists of two independent random variables as shown below.

Hide code cell source
print(my_testfun.prob_input)
Function ID     : McLain
Input ID        : McLain1974
Input Dimension : 2
Description     : Input specification for the McLain's test functions from
                  McLain (1974).
Marginals       :

 No.    Name    Distribution    Parameters    Description
-----  ------  --------------  ------------  -------------
  1      X1       uniform       [ 1. 10.]          -
  2      X2       uniform       [ 1. 10.]          -

Copulas         : Independence

Reference results#

This section provides several reference results of typical UQ analyses involving the test function.

Sample histogram#

Shown below is the histogram of the output based on \(100'000\) random points:

Hide code cell source
xx_test = my_testfun.prob_input.get_sample(100000)
yy_test = my_testfun(xx_test)

plt.hist(yy_test, color="#8da0cb");
plt.grid();
plt.ylabel("Counts [-]");
plt.xlabel("$\mathcal{M}(\mathbf{X})$");
plt.gcf().set_dpi(150);
../_images/612504dc64d82fa37b1b6133ef37adcd61f0a31a55e3191d8808a20d1c7961c4.png

References#

[McL74] (1,2)

D. H. McLain. Drawing contours from arbitrary data points. The Computer Journal, 17(4):318–324, 1974. doi:10.1093/comjnl/17.4.318.