function cluster_center = cluster_initialize_3 ( dim_num, point_num, ...
  cluster_num, point )

%*****************************************************************************80
%
%% cluster_initialize_3() initializes the cluster centers to random values.
%
%  Discussion:
%
%    In this case, each point is randomly assigned to a cluster, and
%    the cluster centers are then computed as the centroids of the points 
%    in the cluster.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    11 February 2014
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer DIM_NUM, the number of spatial dimensions.
%
%    integer POINT_NUM, the number of points.
%
%    integer CLUSTER_NUM, the number of clusters.
%
%    real POINT(POINT_NUM,DIM_NUM), the coordinates of the points.
%
%  Output:
%
%    real CLUSTER_CENTER(CLUSTER_NUM,DIM_NUM), 
%    the coordinates of the cluster centers.
%

%
%  Assign one point to each cluster center.
%
  for i = 1 : cluster_num
    cluster_center(i,1:dim_num) = point(i,1:dim_num);
  end

  cluster_population(1:cluster_num) = 1;
%
%  The rest of the points get assigned randomly.
%
  for i = cluster_num + 1 : point_num
    j = randi ( [ 1, cluster_num ], 1, 1 );
    cluster_center(j,1:dim_num) = cluster_center(j,1:dim_num) ...
      + point(i,1:dim_num);
    cluster_population(j) = cluster_population(j) + 1;
  end
%
%  Now average the points to get the centroid.
%
  for i = 1 : cluster_num
    cluster_center(i,1:dim_num) = cluster_center(i,1:dim_num) ...
      / cluster_population(i);
  end
    
  return
end
