Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slsumstat_blks
Home > sltoolbox > core > slsumstat_blks.m

slsumstat_blks

PURPOSE ^

SLSUMSTAT_BLKS Sums up statistics on all blocks for partitioned data

SYNOPSIS ^

function R = slsumstat_blks(data, statfunc, varargin)

DESCRIPTION ^

SLSUMSTAT_BLKS Sums up statistics on all blocks for partitioned data

 $ Syntax $
   - R = slsumstat_blks(data, statfunc, ...)

 $ Arguments $
   - data:         the data array of cell array of data array filenames
   - statfunc:     the function to compute statistics on data array
   - R:            the sum statistics

 $ Description $
   - R = slsumstat_blks(data, statfunc, ...) computes statistics on
     all data blocks and sums them by plus. When data is an array,
     it just invokes statfunc on it and return, if data is a cell array
     of filenames, it loads data of each block, computes statistics
     blockwise and sums them up to give the final result.

 $ Remarks $
   - The function is widely applicable for diverse types of computation.
     The only conditions is that the function values on the whole matrix
     is equivalent to the sum of function values on all blocks.
 
   - The function values can be either a scalar or an array of any 
     dimensions, provided that the values produced on all blocks have
     equal size.

 $ History $
   - Created by Dahua Lin, on Aug 8th, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
  • slreadarray SLREADARRAY Reads an array from an array file
  • raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
This function is called by:

SOURCE CODE ^

0001 function R = slsumstat_blks(data, statfunc, varargin)
0002 %SLSUMSTAT_BLKS Sums up statistics on all blocks for partitioned data
0003 %
0004 % $ Syntax $
0005 %   - R = slsumstat_blks(data, statfunc, ...)
0006 %
0007 % $ Arguments $
0008 %   - data:         the data array of cell array of data array filenames
0009 %   - statfunc:     the function to compute statistics on data array
0010 %   - R:            the sum statistics
0011 %
0012 % $ Description $
0013 %   - R = slsumstat_blks(data, statfunc, ...) computes statistics on
0014 %     all data blocks and sums them by plus. When data is an array,
0015 %     it just invokes statfunc on it and return, if data is a cell array
0016 %     of filenames, it loads data of each block, computes statistics
0017 %     blockwise and sums them up to give the final result.
0018 %
0019 % $ Remarks $
0020 %   - The function is widely applicable for diverse types of computation.
0021 %     The only conditions is that the function values on the whole matrix
0022 %     is equivalent to the sum of function values on all blocks.
0023 %
0024 %   - The function values can be either a scalar or an array of any
0025 %     dimensions, provided that the values produced on all blocks have
0026 %     equal size.
0027 %
0028 % $ History $
0029 %   - Created by Dahua Lin, on Aug 8th, 2006
0030 %
0031 
0032 %% parse and verify input arguments
0033 
0034 if nargin < 2
0035     raise_lackinput('slsumstat_blks', 2);
0036 end
0037 if ~isnumeric(data) && ~iscell(data)
0038     error('sltoolbox:invalidargs', ...
0039         'data should be either a numeric array or a cell array of strings');
0040 end
0041 
0042 
0043 %% compute
0044 
0045 if isnumeric(data)
0046     R = feval(statfunc, data, varargin{:});
0047 else
0048     n = numel(data);
0049     
0050     % first section
0051     curdata = slreadarray(data{1});
0052     R = feval(statfunc, curdata, varargin{:});
0053     
0054     % other section
0055     if n > 1
0056         for i = 2 : n
0057             curdata = slreadarray(data{i});
0058             curR = feval(statfunc, curdata, varargin{:});
0059             R = R + curR;
0060         end
0061     end
0062 end
0063 
0064 
0065

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com