📄 rsde.html
字号:
<html><head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"> <title>rsde.m</title><link rel="stylesheet" type="text/css" href="../../../m-syntax.css"></head><body><code><span class=defun_kw>function</span> <span class=defun_out>model </span>= <span class=defun_name>rsde</span>(<span class=defun_in>X,options</span>)<br><span class=h1>% RSDE Reduced Set Density Estimator.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Synopsis:</span></span><br><span class=help>% model = rsde(X,options)</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Description:</span></span><br><span class=help>% This function implements the Reduced Set Density Estimator </span><br><span class=help>% [Girol03] which provides kernel density estimate optimal </span><br><span class=help>% in the L2 sense. The density is modeled as the weighted sum </span><br><span class=help>% of Gaussians (RBF kernel) centered in selected subset of </span><br><span class=help>% training data. </span><br><span class=help>%</span><br><span class=help>% The estimation is expressed as a special instance of the</span><br><span class=help>% Quadratic Programming task (see 'help gmnp').</span><br><span class=help>% </span><br><span class=help>% <span class=help_field>Input:</span></span><br><span class=help>% X [dim x num_data] Input data sample.</span><br><span class=help>% options [struct] Control parameters:</span><br><span class=help>% .arg [1x1] Standard deviation of the Gaussian kernel.</span><br><span class=help>% .solver [string] QP solver (see 'help gmnp'); 'imdm' default.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Output:</span></span><br><span class=help>% model [struct] Output density model:</span><br><span class=help>% .Alpha [nsv x 1] Weights of the kernel functions.</span><br><span class=help>% .sv.X [dim x nsv] Selected centers of kernel functions.</span><br><span class=help>% .nsv [1x1] Number of selected centers.</span><br><span class=help>% .options.arg = options.arg.</span><br><span class=help>% .options.ker = 'rbf'</span><br><span class=help>% .stat [struct] Statistics about optimization:</span><br><span class=help>% .access [1x1] Number of requested columns of matrix H.</span><br><span class=help>% .t [1x1] Number of iterations.</span><br><span class=help>% .UB [1x1] Upper bound on the optimal value of criterion. </span><br><span class=help>% .LB [1x1] Lower bound on the optimal value of criterion. </span><br><span class=help>% .LB_History [1x(t+1)] LB with respect to iteration.</span><br><span class=help>% .UB_History [1x(t+1)] UB with respect to iteration.</span><br><span class=help>% .NA [1x1] Number of non-zero entries in solution.</span><br><span class=help>% </span><br><span class=help>% <span class=help_field>Example:</span></span><br><span class=help>% gnd = struct('Mean',[-2 3],'Cov',[1 0.5],'Prior',[0.4 0.6]);</span><br><span class=help>% sample = gmmsamp( gnd, 1000 );</span><br><span class=help>% figure; hold on; ppatterns(sample.X);</span><br><span class=help>% plot([-4:0.1:8], pdfgmm([-4:0.1:8],gnd),'r');</span><br><span class=help>%</span><br><span class=help>% model = rsde(sample.X,struct('arg',0.7));</span><br><span class=help>% x = linspace(-4,8,100);</span><br><span class=help>% plot(x,kernelproj(x,model),'g'); </span><br><span class=help>% ppatterns(model.sv.X,'ob',13);</span><br><span class=help>% Reduction = model.nsv/size(sample.X,2)</span><br><span class=help>%</span><br><span class=help>% See also </span><br><span class=help>% KERNELPROJ, EMGMM, MLCGMM, GMNP.</span><br><span class=help>%</span><br><hr><span class=help1>% <span class=help1_field>About:</span> Statistical Pattern Recognition Toolbox</span><br><span class=help1>% (C) 1999-2005, Written by Vojtech Franc and Vaclav Hlavac</span><br><span class=help1>% <a href="http://www.cvut.cz">Czech Technical University Prague</a></span><br><span class=help1>% <a href="http://www.feld.cvut.cz">Faculty of Electrical Engineering</a></span><br><span class=help1>% <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a></span><br><br><span class=help1>% <span class=help1_field>Modifications:</span></span><br><span class=help1>% 24-jan-2005, VF, Fast QP solver (GMNP) was used instead of QUADPROG.</span><br><span class=help1>% 17-sep-2004, VF, revised</span><br><br><br><hr><span class=comment>% Input arguments</span><br><span class=comment>%-------------------------------------------------------</span><br>[dim,num_data] = size(X);<br><span class=keyword>if</span> <span class=stack>nargin</span> < 2, options = []; <span class=keyword>else</span> options = c2s(options); <span class=keyword>end</span><br><span class=keyword>if</span> ~isfield(options,<span class=quotes>'arg'</span>), options.arg = 1; <span class=keyword>end</span><br><span class=keyword>if</span> ~isfield(options,<span class=quotes>'solver'</span>), options.solver = <span class=quotes>'imdm'</span>; <span class=keyword>end</span><br><br>options.ker = <span class=quotes>'rbf'</span>;<br><br><span class=comment>% Solve associted QP task</span><br><span class=comment>%-------------------------------------------------------</span><br><br><span class=comment>%G2h = 1/((2*pi)^(dim/2)*(sqrt(2)*options.arg)^dim)*...</span><br><span class=comment>% kernel(X,options.ker,options.arg*sqrt(2));</span><br><span class=comment>%Ph = -1/((2*pi)^(dim/2)*options.arg^dim)*...</span><br><span class=comment>% sum(kernel(X,options.ker,options.arg),2)/num_data;</span><br>G2h = kernel(X,options.ker,options.arg*sqrt(2))/sqrt(2);<br>Ph = -sum(kernel(X,options.ker,options.arg),2)/num_data;<br><br>[Alpha,fval,stat]= gmnp(G2h,Ph,options);<br> <br>inx = find(Alpha > 0);<br>model.Alpha = Alpha(inx)/((2*pi)^(dim/2)*options.arg^dim);<br>model.b = 0;<br>model.sv.X = X(:,inx);<br>model.nsv = length(inx);<br>model.pr2 = model.Alpha'*G2h(inx,inx)*model.Alpha;<br>model.options = options;<br>model.stat = stat;<br>model.fun = <span class=quotes>'kernelproj'</span>;<br><br><span class=jump>return</span>;<br><span class=comment>% EOF</span><br></code>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -