% experiment with producing P(K|Z) from P(tau|Z)
% for a case with N=1, MM(1)=3
%
% Kkp(i) is P(i-1 missed target events) for K=k
%
% S(k+1) is sum of Kkp including all possible combinations and permutations
% of the measurement associations with tracks.

  S = zeros( 4, 1);

% K=0:

  K0p = p_poisson( 3, false_alarm_rate)

  S(1) = K0p;

% K=1:

  K1p = zeros(2,1);

  K1p(1) = (1-Pmiss) * p_poisson( 2, false_alarm_rate);
  K1p(2) = Pmiss     * p_poisson( 3, false_alarm_rate);

  K1p

  S(2) = [3 1] * K1p;

% K=2:

  K2p = zeros(3,1);

  K2p(1) = (1-Pmiss)^2       * p_poisson( 1, false_alarm_rate);
  K2p(2) = Pmiss * (1-Pmiss) * p_poisson( 2, false_alarm_rate);
  K2p(3) = Pmiss^2           * p_poisson( 3, false_alarm_rate);

  K2p

  S(3) = [2*3 2*3 1] * K2p;

% K=3:

  K3p = zeros(4,1);

  K3p(1) = (1-Pmiss)^3         * p_poisson( 0, false_alarm_rate);
  K3p(2) = Pmiss * (1-Pmiss)^2 * p_poisson( 1, false_alarm_rate);
  K3p(3) = Pmiss^2 * (1-Pmiss) * p_poisson( 2, false_alarm_rate);
  K3p(4) = Pmiss^3             * p_poisson( 3, false_alarm_rate);

  K3p

  S(4) = [6 3*6 3*3 1] * K3p;

  S

% normalized results

  normalized = S/sum(S)
