Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
How to improve the curve fitting for my data using matlab?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
John D'Errico
il 6 Giu 2018
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 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!