function [X,eigkvot,eigenval]=neigen(antal,A)
%
% [X,eigkvot,eigenval]=neigen(antal,A)
% produces ANTAL number of normally distributed observations with A*A' 
% as Covariance-matrix as well as the eigenvalues and the largest
% eigenvalue/sum of the eigenvalues.
%
% OUTDATA:
% X=the observational vectors (one in each row). 
% EIGKVOT=the largest eigenvalue/sum of the eigenvalues.
% EIGENVAL=a vector containing the eigenvalues
%
% INDATA:
% A= a matrix of size nxm
% ANTAL= the number of (vector-valued) observations to be generated
% with A as the nxm matrix to yield X=A*Z
% where Z are m independent N(0,1)-distributed.
% i.e. X(k,:) is an n-dimensional observation from a normal distribution
% with C=A*A'as covariance-matrix with k=1,2,...,ANTAL
%
X=[];
n=size(A);
C=A*A';
[V D]=eig(C);
eigenval=diag(D);
eigkvot=max(eigenval)/sum(eigenval);
for i=1:antal,
	X(i,:)=(A*normrnd(0,1,n(2),1))';
end ;