#OK to post homework #Natalya Ter-Saakov, Feb 11, 2024, Assignment 7 read "C7.txt": #Problem 3 #LC(N): inputs a positive integer N, larger than 1, and outputs 1 with probability 1/N and 0 otherwise LC:=proc(N) local i: i:=rand(N)(): if i=1 then return 1: fi: return 0: end: #add(x[LC(10)],i=1..10000); #985*x[1]+9015*x[0] #Problem 4 #TestCode(q,n,C,N,K): inputs a q-ari code,C, on n letters (a subset of GF(q)^n, a positive integer N and a large positive integer K and K times does the following: # Constructs, once and for all the table T:=DecodeT(q,n,C) # Picks a random member v, of C for each component of v, with probabiliy 1/N, changes it (you can add 1 mod q), getting a (possibly) distorted vector v1. # See whether T[v1]≠ v. If it is add it to the counter # output evalf(co/K) TestCode:=proc(q,n,C,N,K) local v, co, T, r, i, v1, j: co:=0: T:=DecodeT(q,n,C): r:=rand(1..nops(C)): for i from 1 to K do v:=C[r()]: v1:=[seq(v[j]+LC(N) mod q, j=1..n)]: # print(v,v1,T[v1]): if not T[v1]=v then co+=1: fi: od: evalf(co/K): end: #The failure rate with with q=2, n=7, K=10000, C=GRC(2,7,3): #N=2: 0.9308 #N=3: 0.74 #N=4: 0.5473 #N=5: 0.4119 #N=6: 0.3254 #N=7: 0.2578 #N=8: 0.2099 #N=9: 0.1874 #N=10: 0.1572 #N=15: 0.0742 #N=20: 0.0419 #N=30: 0.0215 #Problem 6 #SA(q,n,M): inputs a basis M of a linear [n,nops(M),d] code outputs Slepian's Standard Array #as a matrix of vectors containing all the vectors in GF(q)^n (alas Fqn(q,n)) such that #the first row is an ordering of the members of the actual code (LtoC(q,M)) with #[0$n] the first entry and the first columns are the coset reprenatives SA:=proc(q,n,M) local SL,C,A,a1,c,i,j,row: C:=LtoC(q,M): c:=nops(C): C:=C minus {[0$n]}: SL:=[[[0$n],op(C)]]: A:=Fqn(q,n) minus {op(SL[1])}: for j from 1 to q^n/c-1 do a1:=minW(n,A): row:=[seq(a1+SL[1][i] mod q, i=1..c)]: SL:=[op(SL),row]: A:=A minus {op(row)}: od: SL: end: minW:=proc(n,A) local min, minV,v,co,e: min:=n: for v in A do co:=0: for e in v do if e>0 then co+=1: fi: od: if co<=min then min:=co: minV:=v: fi: od: minV: end: