%In physics, a three-parameter Lorentzian function is often used, as follows: % f(x;x0,?,I) = I/(1 + ( (x-x0)/? )^2) % I: is the height of the peak. % x0: is the location paremeter, specifying the location of the peak. % ?: is the scale parameter which specifies the half-width at half-maximum (HWHM). % ? is also equal to half the interquartile range and is sometimes called the probable error. %If you would want,e. g., to ?t a Lorentzian y = a1/((x ? a2)^2 + a3) to a data set Xi, Yi, %you should define in MATLAB a function resulting in the sum of the squared residuals % a(1)= I % a(2)= x0 % a(3)= ? function chisq = Assym_Gau_devsum(a,X,Y) %a % a(1) = sigma_0 % a(2) = x0 % a(3) = off-set %Gau = a(3)+1/(sqrt(2*pi)*a(1))*exp( -(X-a(2)).^2 / (2*a(1).^2) );% Gaussian %Gau = 1/(sqrt(2*pi)*a(1))*exp( -(X-a(2)).^2 / (2*a(1).^2) );% Gaussian %Gau = a(3)*exp( -(X-a(2)).^2 / (2*a(1).^2) );% Gaussian %Gau = 1/(sqrt(2*pi)*(a(3)+a(4)))*exp( -(X-a(2)).^2 / (2*a(1).^2) );% Assymetric Gaussian sigma = (a(3)+a(4))/2; skew = ( a(4)-a(3) )/( a(3)+a(4) ); [col,row] = size(X); %col %for i=1:row signe = sign(X-a(2)); %end fprintf('1.a'); %signe = sign(X-a(2)); %signe' %size(signe') %X' %size(X') %signe = 1; %Gau = a(1)*exp( -(X-a(2)).^2 / ( 2*(sigma*(1+skew ).^2) ));% Assymetric Gaussian for i=1:col Gau(i) = a(1)*exp( -0.5*((X(i)-a(2))/(sigma*(1+signe(i)*skew))).^2 ); %Gau_fit(i) = par(1)*exp( -0.5*((Ene(i)-par(2))/(sigma*(1+signe(i)*skew))).^2 ); end csq = (Y - Gau').^2; chisq = sum(csq); %csq %chisq a return