code:fit
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
code:fit [2011/05/14 15:22] – neater code laurenceb | code:fit [2011/05/14 15:24] (current) – neater code laurenceb | ||
---|---|---|---|
Line 3: | Line 3: | ||
bias_gain needs to be initialized to a reasonably sensible value for this to be well behaved. | bias_gain needs to be initialized to a reasonably sensible value for this to be well behaved. | ||
<code matlab> | <code matlab> | ||
- | function bias_gain=nr_fit(data, | + | function bias_gain=nr_fit(data, |
datalenght=size(data)(2) | datalenght=size(data)(2) | ||
- | #bias_gain=[0.0015; | + | %bias_gain=[0.0015; |
bias_gain=initial; | bias_gain=initial; | ||
convergence=0.5; | convergence=0.5; | ||
while(convergence< | while(convergence< | ||
measured=[bias_gain(1), | measured=[bias_gain(1), | ||
- | errors=1.-sum(measured.*measured); | + | errors=1.-sum(measured.*measured); |
corrections=[2*bias_gain(1)*(data(1,: | corrections=[2*bias_gain(1)*(data(1,: | ||
2*bias_gain(3)*(data(3,: | 2*bias_gain(3)*(data(3,: | ||
-2*(bias_gain(2)^2)*(data(2,: | -2*(bias_gain(2)^2)*(data(2,: | ||
- | bias_gain+=pinv(corrections' | + | bias_gain+=pinv(corrections' |
err_mean=sqrt(mean(abs(errors))+1)-1; | err_mean=sqrt(mean(abs(errors))+1)-1; | ||
if(iterations==1) | if(iterations==1) | ||
- | convergence=(err_mean/ | + | convergence=(err_mean/ |
elseif(iterations> | elseif(iterations> | ||
convergence=0.66*convergence+0.34*(err_mean/ | convergence=0.66*convergence+0.34*(err_mean/ |
code/fit.1305386541.txt.gz · Last modified: 2011/05/14 15:22 by laurenceb