function [V,p]=HyperPlaneFit(X);
% HYPERPLANEFIT fits a hyperplane to a set of given points
%   [V,p]=HyperPlaneFit(X); fits a hyperplane of dimension s<n to a
%   set of given points X(i,:) in R^n. The hyperplane is given by
%   y=p+V(:,1:s)*tau (Parametric Form) or by the equations
%   V(:,s+1:n)'*(y-p)=0 (Normal Form)

m=max(size(X));
p=sum(X)'/m;
Xt=X-ones(size(X))*diag(p);
[U,S,V]=svd(Xt,0);