Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
The multiplication to apply to the simplex before choosing
the new point.
Returns
-------
point : numpy array of length N
The coordinates of the suggested new point.
"""
if transform is not None:
simplex = np.dot(simplex, transform)
# choose center if and only if the shape of the simplex is nice,
# otherwise: the center the longest edge
center, _radius = circumsphere(simplex)
if point_in_simplex(center, simplex):
point = np.average(simplex, axis=0)
else:
distances = scipy.spatial.distance.pdist(simplex)
distance_matrix = scipy.spatial.distance.squareform(distances)
i, j = np.unravel_index(np.argmax(distance_matrix), distance_matrix.shape)
point = (simplex[i, :] + simplex[j, :]) / 2
if transform is not None:
point = np.linalg.solve(transform, point) # undo the transform
return point
The linear transform to apply to the simplex vertices
before determining which point to choose. Must be
invertible.
Returns
-------
point : (n,) array
The point that was chosen in the simplex
"""
if transform is not None:
simplex = np.dot(simplex, transform)
# Choose center only if the shape of the simplex is nice,
# otherwise: the center the longest edge
center, _radius = circumsphere(simplex)
if point_in_simplex(center, simplex):
point = np.average(simplex, axis=0)
else:
distances = scipy.spatial.distance.pdist(simplex)
distance_matrix = scipy.spatial.distance.squareform(distances)
i, j = np.unravel_index(np.argmax(distance_matrix), distance_matrix.shape)
point = (simplex[i, :] + simplex[j, :]) / 2
if transform is not None:
point = np.linalg.solve(transform, point) # undo the transform
return tuple(point)