function [ n_data, df, x, fx ] = inverse_chi_square_pdf_values ( n_data )

%*****************************************************************************80
%
%% inverse_chi_square_pdf_values() returns values of the inverse chi square PDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 August 2015
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N_DATA.  The user sets N_DATA to 0 before the first call.  
%    Thereafter, it should simply be the value returned by the previous call.
%
%  Output:
%
%    integer N_DATA.  On each call, the routine increments N_DATA by 1, and
%    returns the corresponding data; when there is no more data, the
%    output value of N_DATA will be 0 again.
%
%    real DF, the degrees of freedom.
%
%    real X, the argument of the function.
%
%    Output real FX, the value of the function.
%
  n_max = 21;

  df_vec = [ ...
     1.0, ...
     2.0, ...
     1.0, ...
     2.0, ...
     1.0, ...
     2.0, ...
     3.0, ...
     4.0, ...
     1.0, ...
     2.0, ...
     3.0, ...
     4.0, ...
     5.0, ...
     3.0, ...
     3.0, ...
     3.0, ...
     3.0, ...
     3.0, ...
    10.0, ...
    10.0, ...
    10.0 ];
  fx_vec = [ ...
    0.08500366602520342, ...
    0.3368973499542734, ...
    0.3661245640481622, ...
    1.026062482798735, ...
    0.4518059816704532, ...
    0.8953274901880941, ...
    1.129514954176133, ...
    1.119159362735118, ...
    0.2419707245191433, ...
    0.3032653298563167, ...
    0.2419707245191433, ...
    0.1516326649281584, ...
    0.08065690817304778, ...
    0.05492391118346530, ...
    0.02166329508030457, ...
    0.01100204146138436, ...
    0.006457369034861447, ...
    0.004162370481945731, ...
    0.0007897534631674914, ...
    0.00001584474249412852, ...
    1.511920090468204E-06 ];
  x_vec = [ ...
    0.10, ...
    0.10, ...
    0.20, ...
    0.20, ...
    0.40, ...
    0.40, ...
    0.40, ...
    0.40, ...
    1.00, ...
    1.00, ...
    1.00, ...
    1.00, ...
    1.00, ...
    2.00, ...
    3.00, ...
    4.00, ...
    5.00, ...
    6.00, ...
    1.00, ...
    2.00, ...
    3.00 ];

  if ( n_data < 0 )
    n_data = 0;
  end

  n_data = n_data + 1;

  if ( n_max < n_data )
    n_data = 0;
    df = 0.0;
    x = 0.0;
    fx = 0.0;
  else
    df = df_vec(n_data);
    x = x_vec(n_data);
    fx = fx_vec(n_data);
  end

  return
end
