skspatial.objects.Points.mean_center

Points.mean_center(return_centroid: bool = False)[source]

Mean-center the points by subtracting the centroid.

Parameters:
return_centroidbool, optional

If True, also return the original centroid of the points.

Returns:
points_centered(N, D) Points

Array of N mean-centered points with dimension D.

centroid(D,) Point, optional

Original centroid of the points. Only provided if return_centroid is True.

Examples

>>> from skspatial.objects import Points
>>> points_centered, centroid = Points([[4, 4, 4], [2, 2, 2]]).mean_center(return_centroid=True)
>>> points_centered
Points([[ 1.,  1.,  1.],
        [-1., -1., -1.]])
>>> centroid
Point([3., 3., 3.])

The centroid of the centered points is the origin.

>>> points_centered.centroid()
Point([0., 0., 0.])