vlt.fit.dogfit
DOGFIT - fit a difference of Gaussians to data
[P,SSE] = vlt.fit.dogfit(X,Y, ...)
Fits the following function to the column vector data in X, Y:
y(x) = a + b*exp(-((x-c).^2)/d^2) - e*exp(-((x-f).^2)/g^2)
P is the parameters [a b c d e f g] and SSE is the summed
squared error between the fit and the data (y).
This function accepts name/value pairs that alter its default
behavior:
--------------------------------------------------------------
| Parameter (default) | |
|-------------------------|----------------------------------|
| random_starts (10) | Number of random search starts |
| a_low (0) | Low search limit for a |
| a_high (0) | High search limit for a |
| a_initial (NaN) | a initial guess (NaN means choose|
| | randomly between limits) |
| b_low (0) | Low search limit for b |
| b_high (100*max(Y)) | High search limit for b |
| b_initial (NaN) | b initial guess (NaN means choose|
| | randomly between limits) |
| c_low (0) | Low search limit for c |
| c_high (0) | High search limit for c |
| c_initial (NaN) | c initial guess (NaN means choose|
| | randomly between limits) |
| d_low (0.00001) | Low search limit for d |
| d_high (2*max(X)) | High search limit for d |
| d_initial (NaN) | d initial guess (NaN means choose|
| | randomly between limits) |
| e_low (0) | Low search limit for e |
| e_high (100*max(Y)) | High search limit for e |
| e_initial (NaN) | e initial guess (NaN means choose|
| | randomly between limits) |
| f_low (0) | Low search limit for f |
| f_high (0) | High search limit for f |
| f_initial (NaN) | f initial guess (NaN means choose|
| | randomly between limits) |
| g_low (0.00001) | Low search limit for g |
| g_high (2*max(X)) | High search limit for g |
| g_initial (NaN) | g initial guess (NaN means choose|
|-------------------------|----------------------------------|
Example:
P = [ 0 10 0 3 2 0 1 ];
x = logspace(-3,1,100);
y = vlt.math.dogfull(x,P);
figure;
plot(x,y);
ylabel('y');
xlabel('x');
[P_fit,err] = vlt.fit.dogfit(x,y);
y_fit = vlt.math.dogfull(x,P_fit);
hold on;
plot(x,y_fit,'g-');
legend('original','fit');