| Description of slcountvote |
slcountvote
PURPOSE 
SLCOUNTRULE Counts the votings to make histogram
SYNOPSIS 
function H = slcountvote(m, n, V, w, countrule)
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
- sllabeledsum SLLABELEDSUM Sums the numbers according to labels
- raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
- slcount SLCOUNT Count the number of sum entities
This function is called by:
- slvote SLVOTE Builds histogram by voting (or fuzzy voting)
SUBFUNCTIONS 
- function H = countvote_nm(V, w, m, n)
- function H = countvote_nmx(V, w, m, n)
- function H = countvote_mmc(V, w, m, n)
- function H = countvote_mms(V, w, m, n)
- function H = countvote_mmns(V, w, m, n)
- function check_Vsize(rulename, V, d1, d2)
SOURCE CODE 
0001 function H = slcountvote(m, n, V, w, countrule)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 if nargin < 5
0060 raise_lackinput('slcountvote', 5);
0061 end
0062
0063 if ~isempty(w)
0064 if ~isequal(size(w), [1 n])
0065 error('sltoolbox:sizmismatch', ...
0066 'The weights size is not consistent with that of sample number');
0067 end
0068 end
0069
0070
0071
0072 switch countrule
0073 case 'nm'
0074 H = countvote_nm(V, w, m, n);
0075 case 'nmx'
0076 H = countvote_nmx(V, w, m, n);
0077 case 'mmc'
0078 H = countvote_mmc(V, w, m, n);
0079 case 'mms'
0080 H = countvote_mms(V, w, m, n);
0081 case 'mmns'
0082 H = countvote_mmns(V, w, m, n);
0083 otherwise
0084 error('sltoolbox:invalidarg', ...
0085 'Invalid counting rule: %s', countrule);
0086 end
0087
0088
0089
0090
0091 function H = countvote_nm(V, w, m, n)
0092
0093 check_Vsize('Nearest Model', V, 1, n);
0094
0095 if isempty(w)
0096 H = zeros(m, 1);
0097 [nums, u] = slcount(sort(V));
0098 H(u) = nums;
0099 else
0100 H = sllabeledsum(w, V, 1:m)';
0101 end
0102
0103
0104 function H = countvote_nmx(V, w, m, n)
0105
0106 check_Vsize('Extended Nearest Model', V, 2, n);
0107
0108 H = sllabeledsum(V(2,:), V(1,:), 1:m, w);
0109
0110
0111 function H = countvote_mmc(V, w, m, n)
0112
0113 check_Vsize('Multi-Model Count', V, m, n);
0114
0115 if isempty(w)
0116 H = sum(V ~= 0, 2);
0117 else
0118 H = (V ~= 0) * w';
0119 end
0120 if issparse(H)
0121 H = full(H);
0122 end
0123
0124
0125 function H = countvote_mms(V, w, m, n)
0126
0127 check_Vsize('Multi-Model Sum', V, m, n);
0128
0129 if isempty(w)
0130 H = sum(V, 2);
0131 else
0132 H = V * w';
0133 end
0134 if issparse(H)
0135 H = full(H);
0136 end
0137
0138
0139 function H = countvote_mmns(V, w, m, n)
0140
0141 check_Vsize('Multi-Model Normalized Sum', V, m, n);
0142
0143 ss = sum(V, 1);
0144 if issparse(ss)
0145 ss = full(ss);
0146 end
0147 ss(ss < eps) = eps;
0148
0149 if isempty(w)
0150 w = 1 ./ ss;
0151 else
0152 w = w ./ ss;
0153 end
0154
0155 H = V * w';
0156 if issparse(H)
0157 H = full(H);
0158 end
0159
0160
0161
0162
0163 function check_Vsize(rulename, V, d1, d2)
0164
0165 if ~isequal(size(V), [d1, d2])
0166 error('sltoolbox:invalidarg', ...
0167 'V should be an %d x %d matrix for the counting rule %s', ...
0168 d1, d2, rulename);
0169 end
0170
Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003
|
|