⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parzenm.m

📁 模式识别工具箱,本人毕业论文时用到的,希望对大家有用!
💻 M
字号:
%PARZENM Estimate Parzen densities%%	W = PARZENM(A,H)%%	D = B*W%% For each of the classes in the dataset A a Parzen distribution% is estimated. The result is stored as a K*C mapping in W, in which% K is the dimensionality of the input space and C is the number% of classes. The desired smoothing parameter(s) should be stored in% the vector H. Default a ml-optimization is performed.%% The mapping W may be applied to a new K-dimensional dataset B,% resulting in a C-dimensional dataset D. The values in D are not% properly scaled.%% See also datasets, mappings, normalm, parzencfunction w = parzenm(a,h)if nargin < 2, h = []; endif nargin < 1 | isempty(a)	w = mapping(mfilename,h);	returnendif ~isa(h,'mapping')	if isempty(h), h = parzenml(a); end	w = parzenc(a,h);	w = set(w,'m',mfilename);else 	w = parzen_map(a,h);endfunction F = parzen_map(T,W)[a,classlist,type,k,c,v,h] = mapping(W);[nlab,lablist,m,k,c,p] = dataset(a);p = p(:)';h = h(:)';[mt,kt] = size(T);if kt ~= k, error('Wrong feature size'); endif length(h) == 1, h = h * ones(1,c); endif length(h) ~= c	error('Wrong number of smoothing parameters')endmaxa = max(max(abs(a)));a = a/maxa;T = T/maxa;h = h/maxa;if isfeatim(T)	F = datgauss(T,h);endalf=sqrt(2*pi)^k;[num,n] = prmem(mt,m);F = ones(mt,c);for j = 0:num-1	if j == num-1		nn = mt - num*n + n;	else		nn = n;	end	range = [j*n+1:j*n+nn];	D = +distm(a,T(range,:));	for i=1:c		I = find(nlab == i);		if length(I) > 0			F(range,i) = mean(exp(-D(I,:)*0.5./(h(i).^2)),1)';		end	endendF = F.*repmat(p./(alf.*h.^k),mt,1);%if max(h) ~= min(h)	% avoid this when possible (problems with large k)%	F = F.*repmat(p./(h.^k),mt,1);%else%	F = F.*repmat(p,mt,1);%endF = F + realmin;%F = F ./ (sum(F')'*ones(1,c));%F = invsig(F);[nlab,lablist,m,k,c,p] = dataset(T);F = dataset(F,getlab(T),classlist,p,lablist);return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -