function [params, outsideValues] = boxparams(x)
% BOXPARAMS - 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.00

% 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.6 $
%	$Date: 2008/01/19 19:28:12 $
%	$Id: boxparams.m,v 1.6 2008/01/19 19:28:12 duncombe Exp duncombe $

%  get the quartiles
temp = quantile(x,[.10 .5 .90]);
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(:)';

