Reputation: 768
I need to fit the curve that you can see in the image, that comes out from a lot of Monte Carlo simulations. I've also uploaded the data to fit in a txt file.
I've tryied to fit the curve with a function of the type :
axexp(b(x^k))
with k<1
.
The results are similar to the experimental points but still far from the fitting function I need.
I've thought to split in different equations the whole range, but I haven't reached a solution yet. I.e. a straight line for the fist part and an exponential for the third. But what about the peak?
Any ideas?
Upvotes: 1
Views: 695
Reputation: 3249
I guess your problem is not only to smooth your curve... If it is, nothing is better than a well-chosen polynomial as pointed by @divanov. So, I have nothing to say about that.
However, as I understood your data describes an empirical distribution (you told us that it came from monte carlo simulations) and if you realy want to find a function that describes your data, you might consider to estimate a well-known distribution with a heavy tail.
There are some of them already cooked in matlab toolbox. I suggest you try for instance Weibull distribution, but you might eventually try other kinds.
Upvotes: 3
Reputation: 6339
Polynomial fitting of 8th degree:
close all; clear all;
fid = fopen('output_red.txt','r');
Z = textscan(fid, '%f %f %f %f %f');
fclose(fid);
X = log(Z{1});
Y = log(Z{2});
p = polyfit(X, Y, 8);
Y2 = polyval(p, X);
plot(exp(X), exp(Y));
hold on
plot(exp(X), exp(Y2), 'r')
legend('Original data','Fitted curve')
print('-dpng','fitted.png')
p
contains polynomial coefficients 1.2737e-05 -9.1262e-04 2.7838e-02 -4.7160e-01 4.8482e+00 -3.0958e+01 1.1990e+02 -2.5649e+02 2.3480e+02
. Using higher degrees of polynomial will result in better precision.
Upvotes: 2