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.

The computer code and data files made available on this web page are distributed under the GNU LGPL license.

**CENTRALIZE** is available in
a MATLAB version.

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

- 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.

- centralize_test.m, runs all the tests;
- centralize_test_output.txt, the output file;
- cube_grid_centralize_test.m, tests cube_grid_centralize();
- cube_random_centralize_test.m, tests cube_random_centralize();
- cube3d_grid_centralize_test.m, tests cube3d_grid_centralize();
- cube3d_grid_plot_test.m, tests cube3d_grid_plot();
- ellipsoid_random_centralize_test.m, tests ellipsoid_random_centralize();
- sphere_random_centralize_test.m, tests sphere_random_centralize();
- triangle_random_centralize_test.m, tests triangle_random_centralize();

Graphics files created include:

- cube_centered_points.png, hypersphere grid points mapped onto a 3D cube, using a centered base point.
- cube_centered_surface.png, the surface of a 3D cube, determined from sample points from a hypersphere grid with a centered base point.
- cube_offcentered_points.png, hypersphere grid points mapped onto a 3D cube, using an off-centered base point.
- cube_offcentered_surface.png, the surface of a 3D cube, determined from sample points from a hypersphere grid with an off-centered base point.

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