fitting a skew distribution
7 views (last 30 days)
Show older comments
I generated some data using a function representing a skew distribution (contains an error function). I try to fit the function using a starting point of the same variables to generate the data but the fit comes out wrong. Not sure why it doesn't fit correctly. Here is the code:
x = (-10:.01:20)';
var = [2 10 6 -0.45 ];
y = var(1)*exp(-(x-var(2)).^2/(var(3)^2)).*(1+erf((x-var(2))*var(4)));
ftype=fittype('a*exp(-(x-b)^2/c^2)*(1+erf(x-b)*d)','coeff',{'a','b','c','d'})
f=fit(x(:),y(:),ftype,'startpoint',var)
plot(f,x,y)
Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!