function.forr08a.onevar
function.forr08a.onevar(x)
One-variable test function that takes a scalar or 1D array input x in the range [0, 1] and returns the corresponding function values. The function is vectorized to handle multiple inputs.
The function is defined as
f(x) = ((6x - 2)^2) * np.sin((6x - 2) * 2)
Parameters
x
np .ndarray
A scalar or 1D NumPy array of values in the range [0, 1].
required
Returns
np .ndarray
np.ndarray: The calculated function values for the input x.
Raises
ValueError
If any value in x is outside the range [0, 1].
Examples
>>> import numpy as np
>>> from spotpython.surrogate.functions.forr08a import onevar
>>> # Single input
>>> print (onevar(np.array([0.5 ])))
[0.9093 ]
>>> # Multiple inputs
>>> x = np.array([0.0 , 0.25 , 0.5 , 0.75 , 1.0 ])
>>> print (onevar(x))
[3.0272 , - 0.2104 , 0.9093 , - 5.9933 , 15.8297 ]