Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to improve the curve fitting for my data using matlab?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I am using the code below to draw a fitting curve for my attached data. I would like to insist that the carve gets closer to the data between x= 4000 and x= 5500. If anyone can let me know how to do it, that would be greatly appreciated. I have attached my data sample herewith.
Thank you.
The code:
clear all; close all; clc;
a = importdata('Data.txt');
X = a(:,1);
Y = a(:,2);
fcn = @(b,x) normcdf(x, b(1), b(2));
NRCF = @(b) norm(Y - fcn(b,X));
B = fminsearch(NRCF, [0; 10]);
Xplot = linspace(min(X), max(X));
figure(1)
plot(X, Y, 'pg')
hold on
plot(Xplot, fcn(B,Xplot))
hold off
grid
text(-50, 0.65, sprintf('\\mu = %.1f\n\\sigma = %.1f', B))
댓글 수: 0
답변 (1개)
John D'Errico
2018년 6월 6일
Think about your data. Think about the model you are trying to fit. If necessary, plot your data. Well, actually, plot it ALWAYS. ALWAYS. ALWAYS. There, if I said it thrice, it must be true.
x = Data(:,1);
y = Data(:,2);
Hmm. That does not look like a normal CDF. Not even close.
Similarly, if it WAS normally distributed, the following would look like a nice, bell shaped curve.
plot(diff(y))
Sorry for laughing, but are you kidding? You are not seriously trying to fit a normal distribution to this? There is no bell shape there. Of course you got a crappy fit.
No matter how hard you try, you will not make it fit better. Pound as hard as you like. All you will get is finely pounded crapola.
Might you convince me that this could be represented as a mixture distribution, a mixture of normals? Perhaps. 3 terms in that mixture might work.
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!