function [means, sigmas, priors] = fit_gaussians(input, target)
% function [means sigmas priors] = fit_gaussians(input, target)
%
% For each target class fit a multi-dimensional gaussian.
% 
% Assumes the targets are stored one column per class.  When the i'th target
% column is greater than 0 it identifies that row as being an element of 
% class i.
%
% Returns the means, the covariance matrices, and the priors.  
%    The ith row of means is the mean of the i'th class
%    invsigmas is a 3D array.  The third index ranges of the classes.
%    priors is a vector. 


numclasses = size(target, 2);

for i = 1:numclasses
  select = target(:,i) > 0;
  size(select)
  data = input(select,:);
  means(i,:) = mean(data);
  sigmas(:,:,i) = cov(data)
  priors(i,1) = size(data, 1) / size(input, 1);
end

