📄 gininorm.m
字号:
function [rateval,znorm] = ginitest(inpvec,gamma);%------------------------------------------------% This function implements the gini normalization% procedure by finding a threshold using the% reverse water-filling procedure.%% inpvec -> Unnormalized inputs.% gamma -> Normalization Factor.% rateval-> Probability vector.% znorm -> threshold factor.%------------------------------------------------[L,M] = size(inpvec);rateval = zeros(1,M);znorm = 0;if gamma > 0, [fthd,ind] = sort(inpvec); target = gamma; zt = 0; curr = M; while zt < target & curr >= 2, zt = sum(fthd(curr:M) - fthd(curr-1)); curr = curr - 1; end; if curr == 1, if zt < target, % Means we have to include the total classes znorm = 1/M*(sum(fthd(curr:M)) - target); for class = curr:M, rateval(ind(class)) = ((inpvec(ind(class)) - znorm)); end; else znorm = 1/(M-1)*(sum(fthd(2:M)) - target); for class = curr+1:M, rateval(ind(class)) = ((inpvec(ind(class)) - znorm)); end; end; else znorm = 1/(M-curr)*(sum(fthd(curr+1:M)) - target); for class = curr+1:M, rateval(ind(class)) = ((inpvec(ind(class)) - znorm)); end; end;end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -