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 slvote
Home > sltoolbox > discrete > slvote.m

slvote

PURPOSE ^

SLVOTE Builds histogram by voting (or fuzzy voting)

SYNOPSIS ^

function H = slvote(models, m, samples, n, evalfunctor, countrule, varargin)

DESCRIPTION ^

SLVOTE Builds histogram by voting (or fuzzy voting)

 $ Syntax $
   - H = slvote(models, m, samples, n, evalfunctor, countrule, ...)

 $ Arguments $
   - models:       The models to be voted for
   - m:            The number of models
   - samples:      The samples (as voters)
   - n:            The number of samples
   - evalfunctor:  The functor to evaluate the votes for samples
                   it should be like the form:
                       V = f(models, samples, ...)
                   The form of V depends on count rule.
   - countrule:    The rule of counting the votes.
   - H:            The built histogram of votes on the models

 $ Description $
   - H = slvote(models, m, samples, n, evalfunctor, countrule, ...) makes 
     histogram on the models using the specified voting method. The basic
     procedure consists of two stages. The first stage is to use the
     evalfunctor to evaluate the votes, and then the histogram is built
     using the votes according to the specified counting rule. 
     If there are m models, then H would be an m x 1 column vector.
     
     This function supports a series of counting ways for voting. 
     Correspondingly, the evalfunctor should have different format of 
     output for different rules.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
  • slvechist SLVECHIST Makes the histogram on prototype vectors by voting

SOURCE CODE ^

0001 function H = slvote(models, m, samples, n, evalfunctor, countrule, varargin)
0002 %SLVOTE Builds histogram by voting (or fuzzy voting)
0003 %
0004 % $ Syntax $
0005 %   - H = slvote(models, m, samples, n, evalfunctor, countrule, ...)
0006 %
0007 % $ Arguments $
0008 %   - models:       The models to be voted for
0009 %   - m:            The number of models
0010 %   - samples:      The samples (as voters)
0011 %   - n:            The number of samples
0012 %   - evalfunctor:  The functor to evaluate the votes for samples
0013 %                   it should be like the form:
0014 %                       V = f(models, samples, ...)
0015 %                   The form of V depends on count rule.
0016 %   - countrule:    The rule of counting the votes.
0017 %   - H:            The built histogram of votes on the models
0018 %
0019 % $ Description $
0020 %   - H = slvote(models, m, samples, n, evalfunctor, countrule, ...) makes
0021 %     histogram on the models using the specified voting method. The basic
0022 %     procedure consists of two stages. The first stage is to use the
0023 %     evalfunctor to evaluate the votes, and then the histogram is built
0024 %     using the votes according to the specified counting rule.
0025 %     If there are m models, then H would be an m x 1 column vector.
0026 %
0027 %     This function supports a series of counting ways for voting.
0028 %     Correspondingly, the evalfunctor should have different format of
0029 %     output for different rules.
0030 
0031 %     You can further specify the following properties:
0032 %       - 'weights':        The weights of samples. They will be multiplied
0033 %                           to the contributions of the samples.
0034 %                           (default = [], if specified, it is 1 x n row)
0035 %       - 'normalized':     Whether to normalize the histogram so that the
0036 %                           sum of the votings to all bins are normalized
0037 %                           to 1. (default = false)
0038 %
0039 % $ History $
0040 %   - Created by Dahua Lin, on Sep 17, 2006
0041 %
0042 
0043 %% parse and verify input arguments
0044 
0045 if nargin < 4
0046     raise_lackinput('slvote', 6);
0047 end
0048 
0049 opts.weights = [];
0050 opts.normalized = false;
0051 opts = slparseprops(opts, varargin{:});
0052 
0053 %% main skeleton
0054 
0055 % make vote
0056 V = slevalfunctor(evalfunctor, models, samples);
0057 
0058 % make histogram
0059 H = slcountvote(m, n, V, opts.weights, countrule);
0060 
0061 % normalize the histogram
0062 if opts.normalized
0063     H = H / sum(H);
0064 end
0065

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

Contact us at files@mathworks.com