from spotoptim.function import sphere
import numpy as np
X = np.array([1.0, 1.0])
sphere(X)array([2.])
N-dimensional Sphere function.
The Sphere function is a simple test function for optimization algorithms. It is characterized by a parabolic-shaped valley. The global minimum is inside the valley and is easy to find for many algorithms.
f(x, y) = x^2 + y^2
f(X) = sum_{i=1}^{N} x_i^2
| Name | Type | Description | Default |
|---|---|---|---|
| X | array - like |
Input points with shape (n_samples, n_features) or (n_features,). Can be a 1D array for a single point or 2D array for multiple points. | required |
| Name | Type | Description |
|---|---|---|
| np.ndarray | np.ndarray: Function values at the input points with shape (n_samples,). |
| Name | Type | Description |
|---|---|---|
| ValueError | If X has fewer than 1 dimension. |
array([2.])