%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; Es = ( a(4)-a(3) )/( a(3)+a(4) ); signe = sign(X-a(2)); sigma2 = (a(7)+a(8))/2; Es2 = ( a(8)-a(7) )/( a(7)+a(8) ); signe2 = sign(X-a(6)); [col,row] = size(X); %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+Es ).^2) ));% Assymetric Gaussian for i=1:col %if signe(i)<=0 Gau(i) = a(5)*exp( -0.5*((X(i)-a(6))/(sigma2*(1+signe2(i)*Es2))).^2 ) + a(1)*exp( -0.5*((X(i)-a(2))/(sigma*(1+signe(i)*Es))).^2 ); %Gau(i) = a(5)*exp( -0.5*((X(i)-a(6))/a(7)).^2 ) + a(1)*exp( -0.5*((X(i)-a(2))/(sigma*(1+signe(i)*Es))).^2 ); %Gau(i) = a(8)*X(i) + a(5)*exp( -0.5*((X(i)-a(6))/a(7)).^2 ) + a(1)*exp( -0.5*((X(i)-a(2))/(sigma*(1+signe(i)*Es))).^2 ); %Gau(i) = a(5)*X(i) + a(1)*exp( -0.5*((X(i)-a(2))/(sigma*(1+signe(i)*Es))).^2 ); %Gau_fit(i) = par(1)*exp( -0.5*((Ene(i)-par(2))/(sigma*(1+signe(i)*Es))).^2 ); %end end csq = (Y - Gau').^2; chisq = sum(csq); %csq %chisq %a return