view 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 source
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);