function [s] = significance(y);
% function [s] = significance(y)
%
% calculates significance function based on the given signal. Significance is defined
% as the ratio of maximum deviation of the signal from its mean value over its standard
% deviation. Significance is a function of time. Significance value at time t takes into
% account the signal up to time t.
%
% Significance function can be used for identification of pulse free area at the
% beginning of the signal and the time position inside the first pulse.
%
% <y> is given signal in 1D array format.
% <s> is calculcated significance function.
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Current state of the project and change history.
%
%	Created by:	Alexander Vostrikov
%	Created on:	07/13/2011
%
%	Version: 1.0
%	Modified by:	Alexander Vostrikov
%	Edited on:	07/13/2011
%
% List of Previous Versions:
%
%
% If you type 'help significance' on the Matlab command window, you will be
% able to see this help documentation.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% beginning of code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

N = size(y);
s = zeros(N);
for i = 1:N
	sigma = std(y(1:i));
	if sigma ~= 0.0
		s(i) = max(abs(y(1:i) - mean(y(1:i)))) / sigma;
	end
end

end

