view general/numerical/cauchy_norm.m @ 6:0ce3c2070089

Removed duplicate code and fixed doc in timed_action.
author samer
date Mon, 14 Jan 2013 14:33:37 +0000
parents e44f49929e56
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);