function y = posneg(x)

%   Y = POSNEG(X) calculates the positive/negative asymmetry Y of the
%   signal vector X.  
%
%   The positive/negative asymmetry, Y, is measured as the product of two
%   ratios:
%      (1) the ratio of duration of periods of positive values in the
%          time series to negative periods, and
%      (2) the ratio of amplitudes of negative values in the time
%          series to positive values.
%

%   Copyright 2003
%   Centre for Nonlinear Dynamics in Physiology and Medicine

pospart = x(find(x>0));
negpart = x(find(x<0));

y = length(pospart)/length(negpart)*rms(negpart)/rms(pospart);

return