function eps = misfit(time_steps,pdf_tuts,pdf_tu,pdf_ts,w) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% %%% Misfit (mean of the differences) between cdf of tu+ts (known from the data), %%% and connvolved cdf of tu (known from the data) and the unknown %%% component, ts; w is the weight of ts cdf relative to conv(tu,ts) cdf in %%% the misfit calcualtion vs tuts cdf %%% %%% time_steps: vector of steps covering the given time range %%% %%% Dmitry Yumashev, 20/11/2019 %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% total_time_steps = length(time_steps); % first vector: convolution (transformed to cdf) of the known tu and unknown ts (both pdfs) [~, cdf_conv] = pdf_convolution(time_steps,pdf_tu,pdf_ts); % second vector: reconstructed cdf of the known tuts distribution cdf_tuts = zeros(total_time_steps,1); cdf_ts = zeros(total_time_steps,1); cdf_tuts(1) = 0; % initial value (just in case) cdf_ts(1) = 0; % initial value (just in case) for i=2:total_time_steps % NOTE the starting value delta = time_steps(i) - time_steps(i-1); cdf_tuts(i) = cdf_tuts(i-1) + pdf_tuts(i-1) * delta; cdf_ts(i) = cdf_ts(i-1) + pdf_ts(i-1) * delta; end % cdf_ts = wblcdf(time_steps,y(1),y(2)); % make sure the dimensions are in agreement if size(cdf_tuts,1) == size(cdf_conv,2) && size(cdf_tuts,2) == size(cdf_conv,1) cdf_conv = transpose(cdf_conv); end % eps = sqrt(sum((cdf_ref - (w * cdf_ts + (1-w) * cdf_conv)).^2) / total_time_steps); % eps = sum(abs(cdf_tuts - cdf_conv)); eps = sum(abs(cdf_tuts - (w*cdf_ts + (1-w)*cdf_conv))) / total_time_steps; %%% end