#OK to post homework #Joseph Koutsoutis, 02-11-2024, Assignment 7 read `C7.txt`: myHelp:=proc(): print(` LC(N), TestCode(q,n,C,N,K), SA(q,n,M) `): end: #1 done #2 I couldn't find the typos. #3 #LC(N) takes as input a positive integer N and outputs 1 with probability 1/N and 0 otherwise LC := proc(N) if rand(1..N)() = 1 then: RETURN(1): else: RETURN(0): fi: end: #4 TestCode := proc(q,n,C,N,K) local T,i,j,co,v,v1,rng: T := DecodeT(q,n,C): co := 0: rng := rand(1..nops(C)): for i from 1 to K do: v := C[rng()]: v1 := v: for j from 1 to n do: if LC(N) = 1 then: v1[j] := v1[j] + 1 mod q: fi: od: if T[v1] <> v then: co += 1: fi: od: evalf(co/K): end: #5 #This function prints the error rates for the values described in problem 5. RunTestCode := proc() local N,q,n,C,K: q:=2: n:=7: K:=10000: C:=GRC(2,7,3): for N in [2,3,4,5,6,7,8,9,10,15,20,30] do: print(N, TestCode(q,n,C,N,K)): od: end: #Here is a table for the values of N and their respective error rates: # N Error Rate # 2 0.9399000000 # 3 0.7385000000 # 4 0.5572000000 # 5 0.4164000000 # 6 0.3368000000 # 7 0.2730000000 # 8 0.2174000000 # 9 0.1864000000 #10 0.1509000000 #15 0.07380000000 #20 0.04330000000 #30 0.02190000000 #6 #MinVec(A) takes as input a set of vectors and outputs a vector with the smallest weight MinVec := proc(A) local v,v_best,w,w_best,zero: zero := [0$nops(A[1])]: v_best := A[1]: w_best := HD(v_best, zero): for v in A[2..nops(A)] do: w := HD(v, zero): if w < w_best then: w_best := w: v_best := v: fi: od: v_best: end: #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,rep: C:=LtoC(q,M): C:=C minus {[0$n]}: SL:=[[[0$n],op(C)]]: A:=Fqn(q,n) minus {op(SL[1])}: while A <> {} do: rep := MinVec(A): SL := [op(SL), map(`+`, SL[1], rep) mod q]: A := A minus {op(SL[-1])}: od: SL: end: