function [params, outsideValues] = boxparams_deep(x)
% BOXPARAMS_DEEP - calculate boxplot parameters for data vector x
%
%   boxparams - calculate boxplot parameters for data vector x
%  function [params, outside_values] = boxparams(x)
%  params = [lowerAdjacentValue lowerQuartile med upperQuartile ...
% 		upperAdjacentValue];
%  output is used by boxplotter

% Copyright (c) 1998 by Datatool
% Revision: 1.0

% This function comes from http://datatool.com/ and appears to have been 
% modified and separated from the rest of the datatool dvt toolbox without 
% comment.
% VERSION:
%	$Revision: 1.5 $
%	$Date: 2008/01/19 19:27:42 $
%	$Id: boxparams_deep.m,v 1.5 2008/01/19 19:27:42 duncombe Exp duncombe $

%  get the quartiles
temp = quantile(x,[.15 .5 .85]);
lowerQuartile = temp(1);
med = temp(2);
upperQuartile = temp(3);
%  get adjacent values
interquartileRange = upperQuartile-lowerQuartile;
%limit = upperQuartile+1.5*interquartileRange;
limit = upperQuartile+1.0*interquartileRange;
index = x<=limit;
upperAdjacentValue = max(x(index));
%limit = lowerQuartile-1.5*interquartileRange;
limit = lowerQuartile-1.0*interquartileRange;
index = x>=limit;
lowerAdjacentValue = min(x(index));
%  concatenate the parameters
params = [lowerAdjacentValue lowerQuartile med upperQuartile ...
	upperAdjacentValue];

%  get outside values
index = x>upperAdjacentValue|x<lowerAdjacentValue;
outsideValues = x(index);
outsideValues = outsideValues(:)';

