// Numbas version: finer_feedback_settings {"name": "Information rate and minimum distance", "extensions": ["codewords", "permutations"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variablesTest": {"condition": "max(minimum_distances)>1 // at least one code has minimum distance greater than 1\nand\nlen(distinct(information_rates))=len(information_rates) // all the codes have different information rates", "maxRuns": 100}, "variables": {"codes": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(\n code(shuffle(allwords(word_lengths[j],2))[0..num_words[j]]),\n j,\n 0..2\n)", "name": "codes", "description": "
Each code picks num_words
random binary words of length word_lengths
Number of words in each code
"}, "minimum_distances": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(minimum_distance(x),x,codes)", "name": "minimum_distances", "description": "Minimum distance of each code
"}, "word_lengths": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(3..6),3)", "name": "word_lengths", "description": "Lengths of the words in each code
"}, "information_rates": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(information_rate(code),code,codes)", "name": "information_rates", "description": "Information rate of each code
"}}, "ungrouped_variables": ["word_lengths", "num_words", "codes", "minimum_distances", "information_rates"], "name": "Information rate and minimum distance", "functions": {"distance_table": {"type": "html", "language": "javascript", "definition": "// table of distances between each of the words in code\n\nvar hamming_distance = Numbas.extensions.codewords.hamming_distance;\n\nvar table = document.createElement('table');\ntable.setAttribute('class','distance-table');\nvar header = document.createElement('tr');\nheader.appendChild(document.createElement('td'));\ntable.appendChild(header);\nvar rows = [];\nfor(var i=0;i$C_1 = \\var{codes[0]}$
\nInformation rate: [[0]]
\nMinimum distance: [[1]]
", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false}, {"customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "gaps": [{"precisionPartialCredit": "0", "mustBeReduced": false, "type": "numberentry", "correctAnswerStyle": "plain", "variableReplacementStrategy": "originalfirst", "mustBeReducedPC": 0, "precisionMessage": "You have not given your answer to the correct precision.", "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "variableReplacements": [], "allowFractions": false, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "minValue": "information_rates[1]", "maxValue": "information_rates[1]", "precision": "3", "unitTests": [], "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "showCorrectAnswer": true, "marks": 1, "showFeedbackIcon": true}, {"showCorrectAnswer": true, "allowFractions": false, "customMarkingAlgorithm": "", "mustBeReduced": false, "correctAnswerFraction": false, "minValue": "minimum_distances[1]", "maxValue": "minimum_distances[1]", "unitTests": [], "correctAnswerStyle": "plain", "showFeedbackIcon": true, "scripts": {}, "extendBaseMarkingAlgorithm": true, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "mustBeReducedPC": 0}], "prompt": "$C_2 = \\var{codes[1]}$
\nInformation rate: [[0]]
\nMinimum distance: [[1]]
", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false}, {"customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "gaps": [{"precisionPartialCredit": "0", "mustBeReduced": false, "type": "numberentry", "correctAnswerStyle": "plain", "variableReplacementStrategy": "originalfirst", "mustBeReducedPC": 0, "precisionMessage": "You have not given your answer to the correct precision.", "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "variableReplacements": [], "allowFractions": false, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "minValue": "information_rates[2]", "maxValue": "information_rates[2]", "precision": "3", "unitTests": [], "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "showCorrectAnswer": true, "marks": 1, "showFeedbackIcon": true}, {"showCorrectAnswer": true, "allowFractions": false, "customMarkingAlgorithm": "", "mustBeReduced": false, "correctAnswerFraction": false, "minValue": "minimum_distances[2]", "maxValue": "minimum_distances[2]", "unitTests": [], "correctAnswerStyle": "plain", "showFeedbackIcon": true, "scripts": {}, "extendBaseMarkingAlgorithm": true, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "mustBeReducedPC": 0}], "prompt": "$C_3 = \\var{codes[2]}$
\nInformation rate: [[0]]
\nMinimum distance: [[1]]
", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false}], "statement": "Find the information rates and minimum distances of the following three codes.
\nRound your answers to 3 decimal places.
", "tags": [], "rulesets": {}, "preamble": {"css": ".distance-table td {\n text-align: center;\n}\n.distance-table th:first-child {\n border-right: 1px solid black;\n}\n.distance-table tr:first-child th {\n border-bottom: 1px solid black;\n}\n.distance-table td.empty {\n background: #eee;\n}", "js": ""}, "type": "question", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "Compute the information rate and minimum distance of some binary codes.
"}, "extensions": ["codewords", "permutations"], "advice": "$C_1 = \\var{codes[0]}$ has $\\var{num_words[0]}$ words, each of length $\\var{word_lengths[0]}$.
\nIts information rate is therefore $\\displaystyle\\frac{\\log_2 \\var{num_words[0]}}{\\var{word_lengths[0]}} = \\var{precround(information_rates[0],3)}$ to 3 decimal places.
\nThe minimum distance $d(C_1)$ of $C_1$ is the smallest Hamming distance between distinct codewords of $C_1$.
\nHere's a table of the Hamming distances between the words in $C_1$.
\n{distance_table(codes[0])}
\nThe minimum distance between distinct codewords of $C_1$ is $d(C_1) = \\var{minimum_distances[0]}$.
\n$C_2 = \\var{codes[1]}$ has $\\var{num_words[1]}$ words, each of length $\\var{word_lengths[1]}$.
\nIts information rate is therefore $\\displaystyle\\frac{\\log_2 \\var{num_words[1]}}{\\var{word_lengths[1]}} = \\var{precround(information_rates[1],3)}$ to 3 decimal places.
\nThe minimum distance $d(C_2)$ of $C_2$ is the smallest Hamming distance between distinct codewords of $C_2$.
\nHere's a table of the Hamming distances between the words in $C_2$.
\n{distance_table(codes[1])}
\nThe minimum distance between distinct codewords of $C_2$ is $d(C_2) = \\var{minimum_distances[1]}$.
\n$C_3 = \\var{codes[2]}$ has $\\var{num_words[2]}$ words, each of length $\\var{word_lengths[2]}$.
\nIts information rate is therefore $\\displaystyle\\frac{\\log_2 \\var{num_words[2]}}{\\var{word_lengths[2]}} = \\var{precround(information_rates[2],3)}$ to 3 decimal places.
\nThe minimum distance $d(C_3)$ of $C_3$ is the smallest Hamming distance between distinct codewords of $C_3$.
\nHere's a table of the Hamming distances between the words in $C_3$.
\n{distance_table(codes[2])}
\nThe minimum distance between distinct codewords of $C_3$ is $d(C_3) = \\var{minimum_distances[2]}$.
", "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/"}]}