gusucode.com > 用粒子滤波算法进行跟踪的matlab代码 > gmm_utilities/gmm_derivative.m

    function J = gmm_derivative(g, s, numerical)
%function J = gmm_derivative(g, s, numerical)
%
% INPUTS:
%   g - gmm
%   s - set of N samples from the domain of g
%   numerical - if 1 then compute Jacobians via numerical approximation,
%       else the default is an analytical solution.
%
% OUTPUT:
%   J - Jacobian of g with respect to s. The i-th row of J is dg/ds(:,i),
%       such that J is (N x D), where D is the gmm domain dimension.
%
% REFERENCES:
%   Ridley, M.F., Generalised Bayesian Estimation for Decentralised Sensor
%       Networks, University of Sydney, Australian Centre for Field
%       Robotics, 2005.
%   Williams, J.L., Gaussian Mixture Reduction for Tracking Multiple
%       Maneuvering Targets in Clutter, Masters thesis, Air Force Institute
%       of Technology, Wright-Patterson Air Force Base, 2003.
%
% Compute the Jacobian dg/ds at each point s. 
%
% Tim Bailey 2006.

if nargin == 2, numerical = 0; end

[D,N] = size(s);
if numerical ~= 1
    % Analytical Jacobian as described in Ridley, p169, and Williams, p3-29
    J = zeros(N,D);
    for i=1:length(g.w)
        v = s - repvec(g.x(:,i), N);
        w = gauss_evaluate(v, g.P(:,:,i));
        J = J - g.w(i) * v' * inv(g.P(:,:,i)) .* repvec(w(:), D); 
    end        
    
else
    % Numerical Jacobian approximation
    for i=1:N
        J(i,:) = numerical_Jacobian(s(:,i), @jacmodel, [], [], g);
    end
end

%
%

function f = jacmodel(s, g)
f = gmm_evaluate(g, s);