function [gm]=geomean2(y)
% % This program calculates the geometric mean, if all of the data are
% % greater than zero; otherwise, the progrma caculates the 
% % arithmetic mean.  
% % 
% Example='';
% y=rand(1, 100000);    % y is the data array
%                       % y can be multidimensional
%
% [gm]=geomean2(y);
% % 
% % Output Variables
% % gm is the mean 
% % 
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% % Program Written by Edward L. Zechmann 
% %                date 16 December 2007
% %            modified 27 December 2007
% %                     added a description and an example
% %                     added comments
% %                     
% %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % 
% % Please feel free to modify this code.
% % 

bb=min(y > 0);

if bb
    gm=prod(y).^(1./length(y));
else
    gm=mean(y);
end

