Mercurial > hg > ishara
diff general/numerical/cauchy_norm.m @ 4:e44f49929e56
Adding reorganised general toolbox, now in several subdirectories.
| author | samer |
|---|---|
| date | Sat, 12 Jan 2013 19:21:22 +0000 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/general/numerical/cauchy_norm.m Sat Jan 12 19:21:22 2013 +0000 @@ -0,0 +1,21 @@ +function l=cauchy_norm(DF,eta,maxit) +% cauchy_norm - Quick and dirty function to fit Cauchy density to data +% +% cauchy_norm :: +% [[N,L]] ~'data', +% real ~'learning rate', +% natural ~'max iterations' +% -> [[1,L]] ~'the norms'. + +w=1./mean(abs(DF)); +for k=1:maxit + y=w*DF; + g=1-mean(y.*score(y)); + w=w.*exp(eta*g); + if all(abs(g))<0.002, break; end; +end +l=1./w; + +function g=score(x) +g=2*x./(1+x.^2); +
