function [R] = ClarkEvans2d(M);

% CL_AND_EV(M,mnnd) --- This function calculates the Clark and Evans index of 
% aggregation.  This is found by the mean nearest-neighbor distance divided by the   
% expected NND. Inputs required are the array M, in the standard format, and the   
% mean NND,found by the MNND function.

N = size(M,1);

% Density of points.
rho = N / (9*4*100*pi);

% Expected nnd, denoted classically as r_E
r_E = 1 / (2 * sqrt(rho));

mnnd = meanNnd2d(M);

% Finds the index, R, which is the output of the function.
R = mnnd / r_E;
