// Numbas version: exam_results_page_options {"name": "Lexicographic parity check matrix - binary ", "extensions": ["codewords", "permutations"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"parts": [{"showCorrectAnswer": true, "allowFractions": false, "correctAnswer": "codeword_matrix(pcm)", "extendBaseMarkingAlgorithm": true, "customMarkingAlgorithm": "", "prompt": "

Write down the lexicographic parity check matrix for $\\operatorname{Ham}_{\\var{if(p=2,'',p)}}(\\var{rows})$.

", "unitTests": [], "correctAnswerFractions": false, "allowResize": true, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "scripts": {}, "type": "matrix", "numColumns": 1, "tolerance": 0, "markPerCell": false, "variableReplacements": [], "marks": 1, "numRows": 1}, {"customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "

Use your parity-check matrix to correct the received word $\\var{received_words[0]}$.

\n

[[0]]

", "unitTests": [], "sortAnswers": false, "scripts": {}, "gaps": [{"answer": "{words[0]+''}", "displayAnswer": "{words[0]+''}", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "matchMode": "regex", "showFeedbackIcon": true, "scripts": {}, "type": "patternmatch", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 1}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "showFeedbackIcon": true}, {"customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "

Use your parity-check matrix to correct the received word $\\var{received_words[1]}$.

\n

[[0]]

", "unitTests": [], "sortAnswers": false, "scripts": {}, "gaps": [{"answer": "{words[1]+''}", "displayAnswer": "{words[1]+''}", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "matchMode": "regex", "showFeedbackIcon": true, "scripts": {}, "type": "patternmatch", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 1}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "showFeedbackIcon": true}], "variables": {"error_positions": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(0..word_length-1),num_words)", "name": "error_positions", "description": "

Positions of the error in each of the received words.

"}, "words": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(hamming_encode(random_word(unencoded_length,2)),num_words)", "name": "words", "description": "

Randomly chosen words from the code - pick a random string of the right length, then encode it.

\n

The testing condition makes sure they're different.

"}, "rows": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..4)", "name": "rows", "description": "

Number of rows in the parity check matrix.

"}, "pcm": {"templateType": "anything", "group": "Ungrouped variables", "definition": "hamming_parity_check_matrix(p,rows)", "name": "pcm", "description": "

Lexicographic parity check matrix for the code.

"}, "received_words": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(error(words[j],error_positions[j]),j,0..num_words-1)", "name": "received_words", "description": "

Received words - introduce one error into each of the original words

"}, "multiply_error": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map((received_words[j]-words[j])[error_positions[j]],j,0..num_words-1)", "name": "multiply_error", "description": "

Amount added to the changed column in each of the received words - the syndrome will be this many times the <error_position>th column of the parity-check matrix.

\n

Not really necessary for a binary code because it's always 1, but this is just copied from the n-ary question.

"}, "num_words": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2", "name": "num_words", "description": "

Number of words to decode.

"}, "word_length": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(p^rows-1)/(p-1)", "name": "word_length", "description": "

Length of each codeword

"}, "syndromes": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(syndrome(word,pcm),word,received_words)", "name": "syndromes", "description": "

Syndrome of each of the received words

"}, "columns": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(codeword(x,p),x,list(transpose(codeword_matrix(pcm))))", "name": "columns", "description": "

Columns of the parity check matrix.

"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2", "name": "p", "description": "

Size of the field in which the code lives

"}, "unencoded_length": {"templateType": "anything", "group": "Ungrouped variables", "definition": "word_length-rows", "name": "unencoded_length", "description": "

Length of a string which can be encoded to a member of this code.

"}}, "ungrouped_variables": ["p", "rows", "pcm", "word_length", "num_words", "unencoded_length", "words", "error_positions", "received_words", "syndromes", "multiply_error", "columns"], "preamble": {"css": "", "js": ""}, "name": "Lexicographic parity check matrix - binary ", "variable_groups": [], "functions": {"nth": {"type": "string", "language": "jme", "definition": "switch(\n n=1,\"first\",\n n=2,\"second\",\n n=3,\"third\",\n n+\"th\"\n)", "parameters": [["n", "number"]]}}, "variablesTest": {"condition": "len(distinct(words))=len(words)", "maxRuns": 100}, "statement": "", "tags": [], "rulesets": {}, "extensions": ["codewords", "permutations"], "type": "question", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Write down a lexicographic parity check matrix for a Hamming code and correct two received codewords.

"}, "advice": "

a)

\n

The lexicographic parity check matrix for $\\operatorname{Ham}(\\var{rows})$ has the following properties:

\n\n

The unique parity-check matrix for $\\operatorname{Ham}(\\var{rows})$ with these properties is

\n

\\[ \\var{codeword_matrix(pcm)} \\]

\n

b)

\n

The word $\\var{received_words[0]}$ has syndrome

\n

\\[ (\\var{received_words[0]}) \\var{transpose(codeword_matrix(pcm))} = (\\var{syndromes[0]}) \\]

\n

$\\var{syndromes[0]}$ is binary for $\\var{error_positions[0]+1}$, so the error is in the {nth(error_positions[0]+1)} digit, and we correct to $\\var{words[0]}$.

\n

c)

\n

The word $\\var{received_words[1]}$ has syndrome

\n

\\[ (\\var{received_words[1]}) \\var{transpose(codeword_matrix(pcm))} = (\\var{syndromes[1]}) \\]

\n

$\\var{syndromes[1]}$ is binary for $\\var{error_positions[1]+1}$, so the error is in the {nth(error_positions[1]+1)} digit, and we correct to $\\var{words[1]}$.

", "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/"}]}