⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 randselect.m

📁 一种新的人脸识别算法程序
💻 M
字号:
function [index1,index2] = randselect(weights)% WBL 22 Sept 2002 To boost ANN, based on time.h r1.9% $Revision: 1.3 $  $Date: 2002/09/25 19:27:44 $%WBL 25 Sep 2002 yeild two separate indexes.%                Remove in and B. They are done outside.%rand('state',0);ntests = size(weights,2);%create wheelwheel = zeros(ntests,1);wheel(1) = weights(1);for i=2:ntests    wheel(i) = weights(i)+wheel(i-1);endu = zeros(ntests,1);t1 = 0;t2 = 0;for t=1:ntests %select randomly ntests using wheel    r = wheel(ntests)*rand;    %Binary chop    bot = 1;     top = ntests;	while (wheel(bot)<r & top>=bot)    	i = floor((top+bot)/2);	    if(r < wheel(i)) top = i - 1;	    else             bot = i + 1;        end	end%while    %bot	if(u(bot)==0) %test 'bot' not assigned choose index1 or index2        if(t1<=t2)            u(bot) = 1;        else            u(bot) = -1;        end    end%if new test	if(u(bot)==1)        t1 = t1 + 1;        index1(t1) = bot;    else        t2 = t2 + 1;        index2(t2) = bot;    endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -