function eps = misfit(time_steps,par_tuts,par_tu,x) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% %%% Misfit (root mean square) between cdf of tu+ts (weibull approximation of the data, with %%% parameters par_tuts = (a_tuts, b_tuts)), and connvolved cdf of tu (weibull %%% approximation of the data, with parameters par_tu = (a_tu, b_tu)) and the unknown %%% component, ts (weibul parameters x = (x(1), x(2))) %%% %%% time_steps: vector of steps covering the given time range %%% %%% Dmitry Yumashev, 20/11/2019 %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% total_time_steps = length(time_steps); y = x(1:2); % w = x(3); % first vector: convolution (transformed to cdf) of the known tu and unknown tx (both pdfs) [~, cdf_conv] = pdf_convolution(time_steps,par_tu,y); a_tuts = par_tuts(1); b_tuts = par_tuts(2); % second vector: known tuts (cdf) cdf_ref = wblcdf(time_steps,a_tuts,b_tuts); % cdf_ts = wblcdf(time_steps,y(1),y(2)); % make sure the dimensions are in agreement if size(cdf_ref,1) == size(cdf_conv,2) && size(cdf_ref,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 = sqrt(sum((cdf_ref - cdf_conv).^2) / total_time_steps); %%% end