function [low, up] = perc_ic(bootpopstat, alpha)
% perc_ic -- Bootstrap-percentile confidence intervals
%
%  Usage
%    [low, up] = boot_per_ic(bootpopstat, stat, alpha)
%
%  Inputs
%    bootpopstat column B-dimensional vector: collection of bootstrap
%                versions of the statistic of interest (ex: median,
%                mean, etc.)
%    stat        the original statistic to be bootstrapped
%    alpha       1-alpha represents the confidence level of the
%                interval output
%			     	  
%  Outputs
%    low         lower bound of the confidence interval
%    up          upper bound of the confidence interval
%
%  Description
%    The data 'bootpopstat' consists of B bootstrap replications of
%    the statistic of interest. The routine outputs the bounds of a
%    confidence interval supposed to contain the parameter of interest
%    with probability at least 1-alpha.
%
%  References
%
%  Efron, B. (1979). Bootstrap Methods: Another Look at the Jacknife. Annals of Statistics.
% See Also

  % Size of the population of bootstrap statistics
  b = size(bootpopstat, 1);

  % Sort the bootstrap statistics
  [v, i] = sort(bootpopstat);

  % Extract the indexes corresponding to alpha/2 and 1-alpha/2 quantiles
  i_l = floor(alpha*(b+1)/2);
  i_u =  b+1 - i_l;

  % Extract the limits of the ic interval
  low = v(i_l);
  up = v(i_u);

% Copyright (c) 2008. Stephan Clemencon
% 
% Built Monday, March 10, 2008 14:55:56
% This is Copyrighted Material

% Local Variables: **
% mode: Matlab **
% End: **