📄 data_outliers3.m
字号:
function [ptsa, nptsa, rt_stats, other_stats, rt_outlier_stats, other_outlier_stats]=data_outliers3(rta, dep_var, round_kind, round_digits, abs_rta, abs_other, sod, num_std, outfile, save_file, row_names, row_unit, col_name, array_names, array_units, varargin)
% % data_outliers: Determine the outliers and return descriptive statistics
% %
% % Syntax:
% %
% % [ptsa, nptsa, rt_stats, other_stats, rt_outlier_stats, ...
% % other_outlier_stats]=data_outliers3(rta, dep_var, round_kind, ...
% % round_digits, abs_rta, abs_other, sod, num_std, outfile, save_file, ...
% % row_names, row_unit, col_name, array_names, array_units, varargin);
% %
% % ********************************************************************
% %
% % Description
% %
% % Program finds outliers based on the data array rta.
% %
% % Descriptive statistics of the data excluding the outliers are
% % calculated for the rta array and the varargin data arrays.
% %
% % Descriptive statistics of the outliers fo teh data based on the rta
% % array are calculated for the rta array and the varargin data arrays.
% %
% % The output descriptive statistics are namely:
% % 1) Arithmetic Mean
% % 2) Robust Mean
% % 3) Standard Deviation
% % 4) 95% confidence interval, two sided, t-distribution
% % 5) Median index
% % 6) Median
% % 7) Minimum
% % 8) Maximum
% %
% %
% % Data_outliers uses the robust mean for finding the outliers.
% % All data outside the range robust_mean +- num_std*(Standard Deviation)
% % are considered outliers.
% %
% % There are several input and output variables which are described in
% % more detail in the sections below respectively.
% %
% % ********************************************************************
% %
% % Input Variables
% %
% % rta=abs(randn(28,8)); % Data array to find outliers and primary
% % % data set to analyze with descriptive statistics
% % % default is abs_rta=0;
% %
% % dep_var=1; % Dependence of the varargin arrays on the rta
% % % arrays. Controls how outliers are chosen.
% % %
% % % 1 outliers are calculated only using the
% % % rta array then applied to all varargin arrays.
% % %
% % % 0 outliers are calculated for the rta array
% % % and independently for all varargin arrays.
% %
% % round_kind=1; % Array of values one element for the rta array
% % % and one element for each varargin array
% % % (see example)
% % % 1 round to specified number of significant
% % % digits
% % %
% % % 0 round to specified digits place
% % %
% % % default is round_kind=1;
% %
% % round_digits=3; % Array of values one element for the rta array
% % % and one element for each varargin array
% % % (see example)% Type of rounding depends on round_kind
% % %
% % % if round_kind==1 number of significant digits
% % % if round_kind==0 specified digits place
% % %
% % % default is round_digits=3;
% %
% % abs_rta=1; % 1 use the absolute value of the rta data to
% % % find the outliers and anlayze the descriptive statistics
% % % 0 or [] do not use absolute value
% % % default is abs_rta=0;
% %
% % abs_other=[]; % Logical array of values one element for the
% % % rta array and one element for each varargin array
% % % (see example)
% % % 1 for an element in the varargin will
% % % use the absolute value of the rta data to
% % % anlayze the descriptive statistics
% % % 0 or [] does not use absolute value
% % %
% % % default is abs_other=zeros(1+length(varargin), 1);
% %
% % sod=0; % 1 surpress outlier detection
% % % 0 find the outliers and remove them from the
% % % statistical analysis
% % % default is sod=1;
% %
% % num_std=1; % Number of Standard deviations to accept data
% % % default is num_std=2;
% %
% % outfile='stat_of_data'; % string filename for saving analyzed data
% % % '.txt' extension is added if not present
% % %
% % % fid is another option if the outfile is
% % % already an existing file data will be written
% % % at the current position of file
% % % default is outfile='outliers_stats';
% %
% % save_file=1; % 1 to save data
% % % 0 for not saving data
% % % default is save_file=1;
% %
% % row_names=[ 20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, ...
% % 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, ...
% % 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000];
% % % Array of values one element for each row of
% % % data in the rta array.
% % % (see example)
% % % can be numbers or a cell array of strings
% % % if empty default is numbers
% % % from 1 to num_rows
% % %
% % % first element is the name of the first row
% % % in the rta array the next elements are the
% % % names of the subsequent row in the rta array.
% % % These same names are used to name the
% % % rows in the varargin arrays.
% % %
% % % default is row_names='';
% %
% % row_unit='Hz'; % Cell array of strings, Cell Arary of Numbers
% % % array of numbers, or single string
% % % One element for each row of
% % % data in the rta array. (see example)
% % % Can also be a single string
% % % one string all rows are assumed
% % % to have the same units
% %
% % % first element is the units of the rta array
% % % the next elements are the units in the
% % % varargin arrays.
% %
% % % default is row_unit='';
% %
% % col_name='Peak Number'; % Single string (see example)
% % % String describing a distinguishing characteristic
% % % of one column from the next column.
% % % could be someting like 'Peak Number'.
% % %
% % % default is col_name='';
% %
% % array_names={'Reverberation Times', 'Signal Levels', 'Background Levels'};
% % % Cell array of strings, Cell array of numbers
% % % array of numbers, or single string
% % % One element for the rta array and one element
% % % for each array in varargin (see example)
% % % Can also be a single string
% % % If one string, then all arrays are assumed
% % % to have the same name.
% % %
% % % first element is the units of the rta array
% % % the next elements are the units in the
% % % varargin arrays.
% % % default is array_names='';
% %
% % array_units={'s', 'dBA', 'dBA'};
% % % Cell array of strings, Cell array of numbers
% % % array of numbers, or single string
% % % One element for the rta array and one element
% % % for each array in varargin (see example)
% % % Can also be a single string
% % % If one string, then all arrays are assumed
% % % to have the same units.
% % %
% % % first element is the units of the rta array
% % % the next elements are the units in the
% % % varargin arrays.
% % %
% % % default is array_units='';
% %
% % varargin % List of arrays of associated with rta array
% % % to statistically describe and analyze.
% % %
% % % The varargin data arrays must have the same
% % % size as the rta array.
% % %
% % % varargin consists of a comma delimited
% % % list of arrays
% % %
% % % array1, array2, ..., arrayn
% % %
% % % array1 ... arrayn are data arrays that need
% % % statistical analysis using the same outliers
% % % as the rta
% % %
% % % units_other_data is a cell array of units for
% % % each of the data arrays. Each of the arrays
% % % has its own, so if there were
% % % arrays1 ... array3 then the
% % % units_other_data={'dB', 'Pascals', 's'};
% % % would be possible units.
% % % There is no default value for varargin.
% %
% % ********************************************************************
% %
% % Output Variables
% %
% % ptsa is the cell array of indices of the data points within the
% % specified number of standard deviations
% %
% % nptsa is the cell array of indices of the data points outside the
% % specified number of standard deviations
% %
% % rt_stats is a cell array of descriptive statistics for the input variable rta
% %
% % other_stats is a cell array of descriptive statistics for the
% % arbitrary input variables varargin
% %
% % rt_outlier_stats is a cell array of descriptive statistics for the
% % outliers from the rta input variable.
% %
% % other_outlier_stats is a cell array of descriptive statistics for the
% % outliers from the arbitrary input variables varargin.
% %
% % ********************************************************************
%
% Example='1';
%
% % Shows an array of random numbers.
%
% rta=abs(randn(28,8)); % Data array to find outliers and primary
% % data set to analyze with descriptive statistics
% % default is rta=0;
%
% dep_var=1; % Dependence of the varargin arrays on the rta
% % arrays. Controls how outliers are chosen.
% %
% % 1 outliers are calculated only using the
% % rta array then applied to all varargin arrays.
% %
% % 0 outliers are calculated for the rta array
% % and independently for all varargin arrays.
%
% round_kind=[1 0 0]; % 1 round to specified number of significant
% % digits.
% %
% % 0 round to specifid digits place
%
% round_digits=[3 0 0]; % Type of rounding depends on round_kind
% %
% % if round_kind==1 number of significant digits
% % if round_kind==0 spcecified digits place
% % 3 round to 3 significant digits
% % 0 round to the ones place
%
% abs_rta=1; % Use the absolute value of the rta data to
% % find the outliers and anlayze the descriptive statistics
%
% abs_other=[]; % logical array
% % Do not use the absolute value of the rta
% % data to anlayze the descriptive statistics
%
% sod=0; % Allow removal of outliers
%
% num_std=1; % Number of standard deviations within range
% % to accept data. All dta within 1 standard
% % deviation of the mean will not be
% % an outlier and will not be removed.
%
% outfile='stat_of_data'; % filename for saving analyzed data is
% % 'stat_of_data.txt'
%
% save_file=1; % Save data to a text file
%
% row_names=[ 20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, ...
% 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, ...
% 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000];
% % Row names can be a constant,
% % arrays of numbers
% % cell arrays of numbers
% % or cell arrays of strings
%
% row_unit='Hz'; % one string all rows are assumed
% % to have the same units
%
% col_name='Microphone Number';
% % string distinguishing one column from
% % the next column
%
% array_names={'Reverberation Times', 'Signal Levels', 'Background Levels'};
% % cell array of strings
% % One string for the rta array and one sring
% % for each array in varargin
%
% array_units={'s', 'dBA', 'dBA'};
% % cell array of strings
% % specifies the units for the rta array and
% % each data array in varargin
% % 1zt string is the units of rta
% % the next n strings are the units of varargin
% %
% % For reverberation times
% % rta is the reverberations times with units of
% % seconds
% %
% % varargin contains two arrays the siganl
% % levels dBA and the background levels in dBA
%
% sigl=100+randn(28,8); % signal levels dBA
% bgl=10+randn(28,8); % background levels dBA
%
% % varargin % List of arrays of associated with rta array
% % % to statistically describe and analyze.
% % %
% % % The varargin data arrays must have the same
% % % size as the rta array.
% % %
% % % varargin consists of a comma delimited
% % % list of arrays
% % %
% % % array1, array2, ..., arrayn
% % %
% % % array1 ... arrayn are data arrays that need
% % % statistical analysis using the same outliers
% % % as the rta
% % %
% % % units_other_data is a cell array of units for
% % % each of the data arrays. Each of the arrays
% % % has its own, so if there were
% % % arrays1 ... array3 then the
% % % units_other_data={'dB', 'Pascals', 's'};
% % % would be possible units.
% %
% %
% % Run the example with the code below.
% [ptsa, nptsa, rt_stats, other_stats, rt_outlier_stats, other_outlier_stats]=data_outliers3(rta, dep_var, round_kind, round_digits, abs_rta, abs_other, sod, num_std, outfile, save_file, row_names, row_unit, col_name, array_names, array_units, sigl, bgl);
%
%
% % In general, the calling arguments are
% % [ptsa, nptsa, rt_stats, other_stats, rt_outlier_stats, other_outlier_stats]=data_outliers3(rta, dep_var, round_kind, round_digits, abs_rta, abs_other, sod, num_std, outfile, save_file, row_names, row_unit, col_name, array_names, array_units, varargin);
%
%
% Example='2';
%
% % Using only 2 columns eliminates most of the descriptive ststistics.
% % Use above code then run the following
%
% rta=abs(randn(28,2)); % Data array to find outliers and primary
% sigl=100+randn(28,2); % signal levels dBA
% bgl=10+randn(28,2); % background levels dBA
%
% [ptsa, nptsa, rt_stats, other_stats, rt_outlier_stats, other_outlier_stats]=data_outliers3(rta, dep_var, round_kind, round_digits, abs_rta, abs_other, sod, num_std, outfile, save_file, row_names, row_unit, col_name, array_names, array_units, sigl, bgl);
%
%
%
%
% Example='3';
%
% % Using sod=1. eliminates removing outliers.
% % Use above code then run the following.
%
% sod=1;
% rta=abs(randn(28,8)); % Data array to find outliers and primary
% sigl=100+randn(28,8); % signal levels dBA
% bgl=10+randn(28,8); % background levels dBA
%
% [ptsa, nptsa, rt_stats, other_stats, rt_outlier_stats, other_outlier_stats]=data_outliers3(rta, dep_var, round_kind, round_digits, abs_rta, abs_other, sod, num_std, outfile, save_file, row_names, row_unit, col_name, array_names, array_units, sigl, bgl);
%
%
%
% % ********************************************************************
% %
% % Subprograms
% %
% % List of Dependent Subprograms for
% % data_outliers3
% %
% %
% % Program Name Author FEX ID#
% % 1) file_extension
% % 2) genHyper Ben Barrowes 6218
% % 3) LMSloc Alexandros Leontitsis 801
% % 4) m_round
% % 5) pow10_round
% % 6) sd_round
% % 7) t_alpha
% % 8) t_confidence_interval
% % 9) t_icpbf
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -