#C9.txt Feb. 21, 2019 Help:=proc() print(`PA1(L) , ArData(L1,H1,N,c), TestP(L,c) , NoisyData(L1,H1,N,c,p) `): end: #L:=[[TadeusBalaban, #Publ , #Citations, #h-index ,1], # [RobertBeals, 2], #.... # [DoronZeilberger, 210,2404, , 2], # [WujunZhang, ]] #1D perceptron algorithm, #PA1(L): inputs a list of pairs [heightIncm,{0,1}] where 0 if she or he did not make it 1 if he or she did #outputs a numnber c a "predictor" that if x>c then they get to be admitted PA1:=proc(L) local i,c,n: c:=0: n:=nops(L): for i from 1 to n do if L[i][2]=1 and L[i][1]c then #False negative then c:=c+L[i][1]: fi: od: c: end: #inputs L1 and H1 (low and high heights in basketball players and the number N of applicants #and a cut-off c that >=c gets 1 (admitted) and 0 (rejected) ArData:=proc(L1,H1,N,c) local L,ra,i,t: ra:=rand(L1..H1): L:=[]: for i from 1 to N do t:=ra(): if t>=c then L:=[op(L),[t,1]]: else L:=[op(L),[t,0]]: fi: od: L: end: #Inputs a data set of pairs [height,1 or 0] and a cut-off c, outputs the #triple # of false negatives and # of false positive, total number of data entries TestP:=proc(L,c) local fn,fp,i: fn:=0: fp:=0: for i from 1 to nops(L) do if L[i][1]>=c and L[i][2]=0 then fp:=fp+1: elif L[i][1]=c gets 1 (admitted) and 0 (rejected) and a prob. p of mis-classifying #outputs the noisy data set NoisyData:=proc(L1,H1,N,c,p) local L,ra,i,t,ra1: ra:=rand(L1..H1): ra1:=rand(0.0..1.0): L:=[]: for i from 1 to N do t:=ra(): if t>=c then if ra1()<=p then L:=[op(L),[t,0]]: else L:=[op(L),[t,1]]: fi: else if ra1()<=p then L:=[op(L),[t,1]]: else L:=[op(L),[t,0]]: fi: fi: od: L: end: