function counterfeit_detection_combinatorial_test ( logn )

%*****************************************************************************80
%
%% counterfeit_detection_combinatorial_test tests counterfeit_detection_combinatorial
%
%  Discussion:
%
%    N = 2^(logn) - 1 coins are given.  All but one have the correct weight.
%    Identify the fake coin in logn weighings.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 March 2019
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Kurt Bryan, Tanya Leise,
%    Making do with less: an introduction to compressed sensing,
%    SIAM Review,
%    Volume 55, Number 3, September 2013, pages 547-566.
%
%  Input:
%
%    integer logn, the number of coins is 2^logn - 1.
%    A value of 3 is typical.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'counterfeit_detection_combinatorial_test\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Test counterfeit_detection_combinatorial,\n' );
  fprintf ( 1, '  which can identify one counterfeit coin among 2^logn-1 coins\n' );
  fprintf ( 1, '  using just logn comparisons.\n' );

  n = 2 ^ logn - 1;
%
%  Set the data.
%
  correct = 17.0;
  coin(1:n,1) = correct;
%
%  Select one coin at random to have the wrong weight.
%
  fake = randi ( [ 1, n ] );
  coin(fake) = coin(fake) + 0.5 * randn ( );

  suspect = counterfeit_detection_combinatorial ( logn, coin, correct );
%
%  Compare actual fake to your suspect.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  %d coins checked using %d comparisons\n', n, logn );
  fprintf ( 1, '  Fake = #%d, Suspect = #%d\n', fake, suspect );

  return
end

