#C26.txt April 29, 2019 Help:=proc(): print(` FT(VOC,A), ENT(L), TRM(VOC,A,I1,J1) `): end: read `EV5.txt`: read `EV3.txt`: #FT(VOC,A): inputs a vocabulary list VOC (a list of lists) and an alphabet A #( a list of letters) and outputs the frequenncy table of ALL letters that show up FT:=proc(VOC,A) local VOC1,X,I1,J: VOC1:=ListTools[Flatten](VOC): J:=add(X[VOC1[I1]],I1=1..nops(VOC1)): J:=[seq(coeff(J,X[A[I1]],1),I1=1..nops(A))]: J/convert(J,`+`): end: ENT:=proc(L) local I1: -add(L[I1]*log[2](L[I1]),I1=1..nops(L)):end: #TRM(VOC,A,I1,J1): inputs a vocabulary set VOC, an alphabet A, and pos. integers I1, J1 #outuputs the nops(A) by nops(A) matrix whose i,j entry is conditional probabity #Letter[J1]=j|Letter[I1]=i TRM:=proc(VOC,A,I1,J1) local T1,T2,K1,K2: for K1 from 1 to nops(A) do T1[A[K1]]:=0: od: for K1 from 1 to nops(A) do for K2 from 1 to nops(A) do T2[A[K1],A[K2]]:=0: od: od: for K1 from 1 to nops(VOC) do T1[VOC[K1][I1]]:= T1[VOC[K1][I1]]+1: T2[VOC[K1][I1],VOC[K1][J1]]:= T2[VOC[K1][I1],VOC[K1][J1]]+1: od: [seq([seq( T2[A[K1],A[K2] ]/T1[A[K1]],K2=1..nops(A) )], K1=1..nops(A))]: end: #MakeWS(VOC1,VOC2): creates a random K1 by K2 matrix each of whose rows #belongs to VOC1 and each of whose columns belongs to VOC2 #K1=nops(VOC1[1]), K2=nops(VOC2[1]): #belong to VOC MakeWS:=proc(VOC1,VOC2) local K1,K2: print(`To be continued in homework `): end: