Find real valued parameters of a complex equation/model by using optimization or curve fitting.

30 Ansichten (letzte 30 Tage)
I am trying to replicate finding the optimized parameters of a Lorentz model defined in the paper titled, "EXTRACTION OF EFFECTIVE METAMATERIAL PARAMETERS BY PARAMETER FITTING OF DISPERSIVE MODEL" (linked here). I've provided the equation and table of paramters below:
I've tried the curve fitting tool and get different results especially when I try to change the bounds. Sometimes I am able to get paramters that match the table above but my confidence in repeatbility isn't high. I've also tried scripting code to use the "fittype", "lsqnonlin", or "fminsearch" but also get different answers as well. In the code below, I'm comparing the fit to the real and imaginary parts of the Lorentz model. The fit to the real data is way off and even though the fit to the imaginary values looks qualitatively good. For the fit to the imaginary part, I get different values for the estimated parameters compared to what's reported in the paper.
%% Parameters in Table
e_inf = 1.62;
wp = 2*pi*14.63*1e9; % GHz
vc = 30.69*1e6; %MHz
mu_s = 1.26;
mu_inf = 1.12;
wo = 2*pi*9.67*1e9; % GHz
delta = 1.24*1e9; % GHz
%%
fo = [7:0.01:12].*1e9; % GHz
w = 2*pi*fo;
mu_eff = mu_inf + ((mu_s - mu_inf)*wo.^2)./(wo.^2 + 1i*w*delta - w.^2); % equation in paper / Lorentz model
real_mu_eff = real(mu_eff);
imag_mu_eff = imag(mu_eff);
x = fo;
y = real_mu_eff;
x2 = fo;
y2 = imag_mu_eff;
myfittype = fittype("real(a+((b-a)*(2*pi*1e9*c).^2)./((2*pi*1e9*c).^2+1i*2*pi*x*d*1e9-x.^2))",...
dependent="y",independent="x",...
coefficients=["a" "b" "c" "d"])
myfit = fit(x',y',myfittype)
figure
plot(myfit,x,y)
myfittype2 = fittype("imag(a2+((b2-a2)*(2*pi*1e9*c2).^2)./((2*pi*1e9*c2).^2+1i*2*pi*x2*d2*1e9-x2.^2))",...
dependent="y2",independent="x2",...
coefficients=["a2" "b2" "c2" "d2"])
myfit2 = fit(x2',y2',myfittype2)
figure
plot(myfit2,x2,y2)
The results I was expecting were: a=1.12, b=1.26, c=9.67, and d=1.24. I 've atttached my attempts with using "lsqnonlin", "lsqcurvefit", and "fminsearch"; however I didn't have success in using those methods either. What is best way to find the parameters of the Lorentz model to get the values in the table above?

Akzeptierte Antwort

Torsten
Torsten am 8 Jan. 2025
Bearbeitet: Torsten am 8 Jan. 2025
I don't know if this helps to get better results, but of course you have to fit real and imaginary part of mu_eff simultaneously, not with two separate calls to "fit".
And I think it's impossible to get a good result for the 4 parameters without supplying bounds and good initial guesses. Both can be supplied via the "fitoptions" ("Lower", "Upper","StartPoint").
  5 Kommentare
Ryban1
Ryban1 am 10 Jan. 2025 um 17:17
Thanks you both @Torsten and @Gayathri I appreciate the help.
One last question to @Torsten on your comment about "For lsqnonlin, the region of attraction to the "correct" parameters is not that large. ", how are you defining region of attraction? Is that determined from the bounds of the problem, cancelling out the 1e18 factor, or something else?
Torsten
Torsten am 10 Jan. 2025 um 18:25
Bearbeitet: Torsten am 10 Jan. 2025 um 18:26
how are you defining region of attraction?
I just tested out a bit on how far the initial guess values for the parameter can be away from the solution for that the method still converges to the correct parameter set.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Gayathri
Gayathri am 8 Jan. 2025
Bearbeitet: Torsten am 8 Jan. 2025
If the output of your fitting process is inconsistent, the fitting algorithm might be sensitive to the initial guess of parameters. We can also experiment with different fitting algorithms that suits the data to be fitted. We can use the "fitoptions" function to specify the "StartPoint", "Method", Tolerance etc.
Please refer to the below code which implements the same.
%% Parameters in Table
e_inf = 1.62;
wp = 2*pi*14.63*1e9; % GHz
vc = 30.69*1e6; %MHz
mu_s = 1.26;
mu_inf = 1.12;
wo = 2*pi*9.67*1e9; % GHz
delta = 1.24*1e9; % GHz
%%
fo = [7:0.01:12].*1e9; % GHz
w = 2*pi*fo;
mu_eff = mu_inf + ((mu_s - mu_inf)*wo.^2)./(wo.^2 + 1i*w*delta - w.^2); % equation in paper / Lorentz model
real_mu_eff = real(mu_eff);
imag_mu_eff = imag(mu_eff);
x = fo;
y = real_mu_eff;
x2 = fo;
y2 = imag_mu_eff;
opts = fitoptions('Method', 'NonlinearLeastSquares', ...
'StartPoint', [1.5, 2, -1, 1], ... % Example initial guesses
'MaxIter', 100, ...
'TolFun', 1e-8);
myfittype = fittype("real(a+(((b-a)*(2*pi*1e9*c).^2)./((2*pi*1e9*c).^2+1i*2*pi*x*d*1e9-x.^2)))",...
dependent="y",independent="x",...
coefficients=["a" "b" "c" "d"], ...
options=opts);
myfit = fit(x',y',myfittype)
myfit =
General model: myfit(x) = real(a+(((b-a)*(2*pi*1e9*c).^2)./((2*pi*1e9*c).^2+1i*2*pi*x*d*1e9- x.^2))) Coefficients (with 95% confidence bounds): a = 1.12 (1.12, 1.12) b = 1.26 (1.26, 1.26) c = -1.539 (-1.539, -1.539) d = 0.03141 (0.03141, 0.03141)
figure
plot(myfit,x,y)
opts1 = fitoptions('Method', 'NonlinearLeastSquares', ...
'StartPoint', [0, -1, -2, 1], ... % Example initial guesses
'MaxIter', 100, ...
'TolFun', 1e-8);
myfittype2 = fittype("imag(a2+(((b2-a2)*(2*pi*1e9*c2).^2)./((2*pi*1e9*c2).^2+1i*2*pi*x2*d2*1e9-x2.^2)))",...
dependent="y2",independent="x2",...
coefficients=["a2" "b2" "c2" "d2"], ...
options=opts1);
myfit2 = fit(x2',y2',myfittype2)
myfit2 =
General model: myfit2(x2) = imag(a2+(((b2-a2)*(2*pi*1e9*c2).^2)./((2*pi*1e9*c2).^2+1i*2*pi*x2*d2*1e9- x2.^2))) Coefficients (with 95% confidence bounds): a2 = 20.63 (20.61, 20.64) b2 = 20.77 (20.75, 20.78) c2 = -1.539 (-1.539, -1.539) d2 = 0.03141 (0.03141, 0.03141)
figure
plot(myfit2,x2,y2)
I am able to obtain a consistent output as shown below using this approach.
You can also try experimenting with other parameters within "fitoptions" function for better and accurate curve fitting.
For more information on "fitoptions" function, please refer to the below documentation link.
Hope you find this information helpful.
  1 Kommentar
Ryban1
Ryban1 am 9 Jan. 2025
Thank you for your response, I know that the parameters cannot be negative and will investigate upper bounds to further constrain the problem. I would like the start point to be [0,0,0,0] or random. I experimented with this in the curve fitting app and ran into issues and will report back what they were. With the change to generating the fits through scripting, I'm still working out which method is best between "lsqnonlin", "lsqcurvefit", and "fminsearch" as I would like to verify and have confidence in my ability to find the fit for data where the prior would come from a simulation of a different design.
Do you know how to apply the different methods fit to a complex funtion so that way there is a similtaneous fit to the equation "mu_eff"? I only showed the individual fits for demonstration purposes and to understand the discrepancies.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by