% x98 - data setup for 2 parabolic tracks
%
% for use in measuring get_perm() run time

if( K == 1)
    error( 'use only K > 1 with x98');
end

  N = 11;			% N data samples

  MM_max = 10;

% generate false detections
%
  false_alarm_rate = 2;         % average number of false alarms per unit time

  n_false_detect = (MM_max - 2)*ones(1,N);

% generate missed target events
%
  Pmiss = 0.2;				% probability of a missed target event

  n1 = ones(1,N);		% n1 == 1 when target 1 is not missed
  n2 = ones(1,N);		% n2 == 1 when target 2 is not missed

  MM = n1 + n2 + n_false_detect;	% measurement counter array

  M = MM_max + 1;			% M states

  XY_offset = [0, cumsum(MM(1:N-1))];	% XY measurement offset indices

% apriori costs for missed target events
%
% Cmiss(n+1,K) is -log( P(n target events)) apriori cost
%
  Cmiss = get_Cmiss( Pmiss, MM_max);

% apriori costs for false detections
%
% Cfalse(m+1) is -log(P(m false detections))

  Cfalse = get_Cfalse( false_alarm_rate, MM_max);

% generate XY measurements
%
  dt = 4/(N-1);			% time will go from 0 to 4
   t = [0:N-1]*dt;

  xy1_orig = [ t; 2*(t.*(1-t/4))];

  xy2_orig = [ t; 4-2*(t.*(1-t/4))];

  if(TEST)
    Kn = 0.0;
  else
    Kn = 0.01;	% measurement noise variance
  end

  xy1 = xy1_orig + sqrt(Kn) * randn( size(xy1_orig));
  xy2 = xy2_orig + sqrt(Kn) * randn( size(xy2_orig));

  missed_cost = log(16);	% volume is x,y = 0..4,0..4

  XY = zeros(2,sum(MM));

  for i = 1:N
    ii = XY_offset(i);
    if( n1(i) ~= 0)
      ii = ii + 1;
      XY(:,ii) = xy1(:,i);		% target #1
    end
    if( n2(i) ~= 0)
      ii = ii + 1;
      XY(:,ii) = xy2(:,i);		% target #2
    end
    for j = 1:n_false_detect(i)		% false detections
      if( TEST)
        XY(:,ii+j) = HUGE_VAL * ones(2,1);	% for testing
      else
        XY(:,ii+j) = 4 * rand(2,1);	% uniform distribution over 0..4
      end
    end
  end

  zstate = 0;	% initial state unknown

  z = [1:N];	% time index for dummy z data

  setup_combos_fake;	% setup global variables: perms, combos, unique_perms, MP, M

  L = 8;

  Winc = rand( L*K*M, MM_max+1);

% now run x98_t
