// Numbas version: exam_results_page_options {"name": "Find the syndrome of a word in a linear code", "extensions": ["codewords", "permutations"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "variables": {"word": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(\n random(set_generated_by(G_words) except (G_words+[zero(word_length,field_size)])),\n random(allwords(word_length,field_size) except zero(word_length,field_size))\n)", "description": "

A randomly chosen word - 50% of the time it's picked from the code, 50% of the time it's a completely random word.

", "name": "word"}, "dimension": {"group": "Ungrouped variables", "templateType": "anything", "definition": "3", "description": "

Dimension of the code - number of rows in the generating matrix.

", "name": "dimension"}, "G_dual": {"group": "Ungrouped variables", "templateType": "anything", "definition": "codeword_matrix(parity_check_matrix(M))", "description": "

Parity check matrix for $M$ (a generator matrix for the dual code of $M$)

", "name": "G_dual"}, "G": {"group": "Ungrouped variables", "templateType": "anything", "definition": "codeword_matrix(G_words)", "description": "

A random generating matrix for the code, not in standard form.

", "name": "G"}, "M": {"group": "Ungrouped variables", "templateType": "anything", "definition": "identity_left(A)", "description": "

Standard generating matrix for the code.

", "name": "M"}, "word_length": {"group": "Ungrouped variables", "templateType": "anything", "definition": "dimension+random(3..5)", "description": "

Length of each word in the code

", "name": "word_length"}, "word_is_in_code_explanation": {"group": "Ungrouped variables", "templateType": "anything", "definition": "if(word_is_in_code,\n \"$\\\\operatorname{syn} w = \\\\mathbf{0}$, so $w$ is in the code.\", \n \"$\\\\operatorname{syn} w \\\\neq \\\\mathbf{0}$, so $w$ is not in the code.\"\n)", "description": "", "name": "word_is_in_code_explanation"}, "G_words": {"group": "Ungrouped variables", "templateType": "anything", "definition": "shuffle(set_generated_by(M))[0..dimension]", "description": "

The generating matrix presented to the student, as a list of codewords.

\n

The variable testing condition ensures these words are linearly independent.

", "name": "G_words"}, "A": {"group": "Ungrouped variables", "templateType": "anything", "definition": "repeat(codeword(repeat(random(0..field_size-1),word_length-dimension),field_size),dimension)", "description": "

The generating matrix is $I_{dim}|A$, where $A$ is random.

", "name": "A"}, "word_is_in_code": {"group": "Ungrouped variables", "templateType": "anything", "definition": "word_syndrome=zero(len(word_syndrome),field_size)", "description": "

Word is in the code if its syndrome is zero.

", "name": "word_is_in_code"}, "field_size": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(2,3,5)", "description": "", "name": "field_size"}, "nary": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[\"\",\"unary\",\"binary\",\"ternary\",\"$4$-ary\",\"$5$-ary\"][field_size]", "description": "", "name": "nary"}, "word_syndrome": {"group": "Ungrouped variables", "templateType": "anything", "definition": "syndrome(word,parity_check_matrix(m))", "description": "

Syndrome of word with respect to the parity check matrix.

", "name": "word_syndrome"}, "dual_dimension": {"group": "Ungrouped variables", "templateType": "anything", "definition": "word_length-dimension", "description": "

Dimension of the dual code

", "name": "dual_dimension"}}, "ungrouped_variables": ["field_size", "nary", "dimension", "word_length", "dual_dimension", "A", "M", "G_words", "G", "G_dual", "word", "word_syndrome", "word_is_in_code", "word_is_in_code_explanation"], "name": "Find the syndrome of a word in a linear code", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Given a generator matrix for a linear code, write a parity check matrix, compute the syndrome of a word, and decide if it's a codeword.

"}, "functions": {"identity_right": {"type": "list", "language": "javascript", "definition": "var k = words.length;\nvar field_size = words[0].field_size;\nvar out = [];\nfor(var i=0;iFind the standard parity check matrix $\\mathrm{H}$ for $C$.

\n

$\\mathrm{H} = $ [[0]]

", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"showCorrectAnswer": true, "markPerCell": false, "allowFractions": false, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "correctAnswer": "G_dual", "allowResize": true, "unitTests": [], "correctAnswerFractions": false, "showFeedbackIcon": true, "scripts": {}, "type": "matrix", "numColumns": 1, "tolerance": 0, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": "3", "numRows": 1}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0, "sortAnswers": false}, {"showCorrectAnswer": true, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "

Find the syndrome of $\\var{word}$ with respect to the parity check matrix $\\mathrm{H}$.

\n

$\\operatorname{syn}(\\var{word}) = $ [[0]]

", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"answer": "{word_syndrome+''}", "showCorrectAnswer": true, "displayAnswer": "{word_syndrome+''}", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "matchMode": "regex", "showFeedbackIcon": true, "scripts": {}, "type": "patternmatch", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": "2"}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0, "sortAnswers": false}, {"displayType": "radiogroup", "showCorrectAnswer": true, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "matrix": "matrix(if(word_is_in_code,[[1],[0]],[[0],[1]]))", "choices": ["

Yes

", "

No

"], "prompt": "

Is $\\var{word}$ a codeword?

", "unitTests": [], "shuffleChoices": false, "showFeedbackIcon": true, "scripts": {}, "maxMarks": 0, "type": "1_n_2", "minMarks": 0, "displayColumns": 0, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0}], "variablesTest": {"condition": "linearly_independent(G_words)", "maxRuns": 100}, "statement": "

$C$ is a {nary} linear code with generator matrix

\n

\\[ \\mathrm{G} =\\var{G} \\]

", "tags": [], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "extensions": ["codewords", "permutations"], "advice": "

First, row-reduce $\\mathrm{G}$ to obtain a standard generator matrix $\\mathrm{M}$ for the code

\n

\\[ \\mathrm{G}' = \\var{codeword_matrix(M)} \\]

\n

This is in the form $(\\mathrm{I}_{\\var{dimension}}|\\mathrm{A})$. The standard parity check matrix is then $(-\\mathrm{A^T}|\\mathrm{I}_{\\var{word_length-dimension}})$, i.e.

\n

\\[ \\mathrm{H} = \\var{G_dual} \\]

\n

If $w = \\var{word}$ then $\\operatorname{syn} w = w \\mathrm{H^T} = \\var{word_syndrome}$.

\n

{word_is_in_code_explanation}

", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/3/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/3/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}