function [xe] = MomentPreserv(a)

%Metoda pro nalezení hrany "moment preservation", viz T. Luhmann, Close
%Range Photogrammetry, str. 348, "a" je vstupni rada hodnot, "xe" je
%subindex nalezene hrany

b = size(a,2);
m1 = sum(a)/b;
m2 = sum(a.^2)/b;
m3 = sum(a.^3)/b;
SIG2 = m2 - m1^2;
s1 = (m3+2*m1^3-3*m1*m2)/SIG2^(3/2);
p1 = 0.5*(1+s1*(1/(4+s1^2))^0.5);
xe = (b-1)*p1;

end

