# CENTRALIZE Estimate a Centroid In Arbitrary Dimension

CENTRALIZE is a MATLAB library which estimates the centroid and radius of a shape, or a set of data points, in a space of arbitrary dimension.

We may have been given a way to random sample the shape; we may have been given an organized way to sample; we may have a function that can be evaluated to determine what points belong to the shape. We may already know that the shape is a sphere, ellipse, polytope or convex body. There may be a weight or a weight function associated with points.

The simplest approach estimates the centroid of the shape as the average of the sampled points, and the radius as the average distance of the samples to the estimated centroid. It is interesting to observe the behavior of the error of such an estimate for a fixed number of sample points as the spatial dimension increases.

### Languages:

CENTRALIZE is available in a MATLAB version.

### Related Programs:

RANDOM_DATA, a MATLAB library which generates sample points for various probability distributions, spatial dimensions, and geometries, including the M-dimensional simplex.

### Source Code:

• bisect_characteristic.m, uses bisection to find a transition point, along a given direction, for a characteristic function in multidimensions.
• cube_characteristic.m, evaluates the characteristic function for a cube in M dimensions.
• cube_grid.m, projects hypersphere grid points onto an MD cube, trying both a centered and an off-centered base point.
• cube_grid_centralize.m, generates hypersphere grid points onto an MD cube, then determines their centroid, and maximum and minimum radius.
• cube3d_grid.m, projects hypersphere grid points onto a 3D cube, trying both a centered and an off-centered base point.
• cube3d_grid_centralize.m, generates hypersphere grid points onto a 3D cube, then determines their centroid, and maximum and minimum radius.
• cube3d_grid_plot.m, displays the surface, and the surface plus projected hypersphere grid points, for a 3D cube surface.
• cube_random_centralize.m, generates random points on a given cube of spatial dimension M, then determines their centroid, and maximum and minimum radius.
• cube_surface_sample.m, returns a set of points on the surface of a given cube in M dimensions, chosen uniformly at random.
• ellipsoid_random_centralize.m, generates a set of random points on a given ellipsoid, then determines their centroid and average radius.
• ellipsoid_surface_sample.m, returns a set of points on the surface of a given ellipsoid in M dimensions, chosen uniformly at random.
• r8mat_house_axh.m, computes A*H where H is a compact Householder matrix.
• r8mat_orth_uniform.m, returns a random orthogonal matrix.
• r8vec_direct_product.m, forms the elements of the direct product of R8VEC's.
• r8vec_house_column.m, defines a Householder premultiplier that "packs" a column.
• sphere_random_centralize.m, generates a set of random points on a given sphere, then determines their centroid and average radius.
• sphere_01_surface_sample.m, returns a set of points on the surface of the unit sphere in M dimensions, chosen uniformly at random.
• sphere_surface_sample.m, returns a set of points on the surface of a given sphere in M dimensions, chosen uniformly at random.
• timestamp.m, prints the current YMDHMS date as a timestamp;
• triangle_area_sample.m, returns a set of points in the interior of a given triangle in 2D, chosen uniformly at random.
• triangle_random_centralize.m, generates a set of random points on the surface (boundary) of a given triangle in 2D, then estimates the location of the centroid.
• triangle_surface_sample.m, returns a set of points on the surface (boundary) of a given triangle in 2D, chosen uniformly at random.

### Examples and Tests:

Graphics files created include:

You can go up one level to the MATLAB source codes.

Last revised on 21 May 2013.