필터 지우기
필터 지우기

How to find a curve of best fit

조회 수: 2 (최근 30일)
Stashu Kozlowski
Stashu Kozlowski 2021년 3월 20일
댓글: Star Strider 2021년 3월 20일
I have the following set of data.
And from the looks of it it follows something along the lines of a log normal distrabution. But im having trouble fitting a log norm fit to it. How can I fit it? I have attached the data file for referance as well.
Update: I have come to realize that the data is not normalized so you cannot fit a proper log-norm curve to it. So i would first need to find the area under the data.

답변 (2개)

Star Strider
Star Strider 2021년 3월 20일
Using a completely different approach (System Identification Toolbox):
D = readmatrix('RLC1.xls');
t = D(:,1);
s = D(:,2);
Ts = mean(diff(t));
Tsd = std(diff(t));
Fs = 0.25;
[sr,tr] = resample(s,t,Fs);
Fn = Fs/2;
figure
plot(tr, sr)
grid
L = numel(tr);
FTs = fft(s)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, imag(FTs(Iv)))
grid
ylim([-1 1]*0.0005)
u = [1; zeros(L-1,1)];
tdd = iddata(sr, u, 1/Fs);
sys = tfest(tdd,3,2)
figure
compare(tdd,sys)
producing this transfer function data:
sys =
From input "u1" to output "y1":
0.007132 s^2 + 0.0004604 s + 1.881e-06
-------------------------------------------
s^3 + 0.01617 s^2 + 9.041e-05 s + 7.589e-08
Continuous-time identified transfer function.
Parameterization:
Number of poles: 3 Number of zeros: 2
Number of free coefficients: 6
Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using TFEST on time domain data "tdd".
Fit to estimation data: 95.47%
FPE: 4.55e-06, MSE: 4.304e-06
and this compare plot:
.
  댓글 수: 4
Stashu Kozlowski
Stashu Kozlowski 2021년 3월 20일
편집: Stashu Kozlowski 2021년 3월 20일
You are right that this is not really a lognormal probability distrabution. I was hoping I could normalize the data set and then applying a lognormal. This is usefull as it would allow me to obtain the mean, median, and mode rather easily.
Star Strider
Star Strider 2021년 3월 20일
If you want to fit it using the ‘lnf’ function, you would likely need to add a third ‘scaling’ parameter so that it would fit the curve:
lnf = @(p,x) p(3).*exp(-(log(x)-p(1)).^2./(2*p(2).^2)) ./ (x.*p(2)*sqrt(2*pi));
P = fminsearch(@(p)norm(s-min(s) - lnf(p,t)), rand(3,1));
A parameter set of about [5, 0.5, 75] produces a reasonable fit, so use those instead of the rand call as the initial parameter estimates.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2021년 3월 20일
Ratio of two polynomials of degree 2 fits quite well, with approximate coefficients
P = [0.00213762295171613 56.4867705538076 455.003715200478]
Q = [1 -51.094359290793 32989.9993982203]
yfit = polyval(P, x) ./ polyval(Q,x);
This was using cftool, 'rat22' fit.

카테고리

Help CenterFile Exchange에서 Linear Model Identification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by