// Numbas version: finer_feedback_settings
{"name": "Template 1 for Workshop", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {"norm": {"definition": "\n var b=a;\n var s=-b[x];\n for(i=0;i
\n
2) The total number of {things}s who are {drk} is $\\var{tc[u]}$ hence the probability that a random {things} from this survey is {drk} is $\\displaystyle \\frac{ \\var{tc[u]}}{\\var{n}}=\\var{ans[1]}$ to 3 decimal places.
\n\n
3) Looking at the table there are $\\var{ve}$ {things}s that are {oneof}. Hence the probability is $\\displaystyle \\frac{ \\var{ve}}{\\var{n}}=\\var{ans[2]}$ to 3 decimal places.
\n\n
4) These are the {things}s that are not {drk}, and hence there are $\\var{n}-\\var{tc[u]}=\\var{n-tc[u]}$ of them (see answer to part b)), and the probability of randomly selecting one is $\\displaystyle \\frac{ \\var{n-tc[u]}}{\\var{n}}=\\var{ans[3]}$ to 3 decimal places.
\n\n
5)Looking at the table we see that the number corresponding to {catattrib1} is $\\var{ce1}$. Hence the probability of randomly selecting one is $\\displaystyle \\frac{ \\var{ce1}}{\\var{n}}=\\var{ans[4]}$ to 3 decimal places.
\n6) As in the last question, looking at the table we see that the number corresponding to {catattrib2} is $\\var{ce2}$. Hence the probability of randomly selecting one is $\\displaystyle \\frac{ \\var{ce2}}{\\var{n}}=\\var{ans[5]}$ to 3 decimal places.
\n\n
7) We know from question a) that the probability of selecting a {somecat} {things} is, $\\displaystyle \\frac{ \\var{sumr[t]}}{\\var{n}}$, after this we now have $\\var{sumr[t]-1} $ {somecat} {things}s amongst the $\\var{n-1}$ left, and the probability of yet again selecting one of these is $\\displaystyle \\frac{ \\var{sumr[t]-1}}{\\var{n-1}}$. So the probability of selecting two is $\\displaystyle \\frac{ \\var{sumr[t]}\\times \\var{sumr[t]-1}}{\\var{n}\\times\\var{n-1}}=\\var{ans[6]}$ to 3 decimal places.
\n8) The probability of selecting a {things} who is {drk1} is $\\displaystyle \\frac{ \\var{tc[u1]}}{\\var{n}}$, after this we now have $\\var{tc[u1]-1}$ {drk1} {things}s amongst the $\\var{n-1}$ left, and the probability of yet again selecting one of these is $\\displaystyle \\frac{ \\var{tc[u1]-1}}{\\var{n-1}}$. So the probability of selecting two is $\\displaystyle \\frac{ \\var{tc[u1]}\\times \\var{tc[u1]-1}}{\\var{n}\\times\\var{n-1}}=\\var{ans[7]}$ to 3 decimal places.
\n9) Since there are $\\var{r[t][u]}$ {somecat} {things}s from the $\\var{tc[u]}$ {things}s that are {drk} the probability of selecting one is $\\displaystyle \\frac{\\var{r[t][u]}}{\\var{tc[u]}}= \\var{ans[8]}$ to 3 decimal places.
\n", "rulesets": {}, "parts": [{"prompt": "Find the following probabilities that a randomly chosen {things} involved in this survey:
\n(Enter all probabilities to 3 decimal places)
", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "ans[0]", "minValue": "ans[0]", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "ans[1]", "minValue": "ans[1]", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "ans[2]", "minValue": "ans[2]", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "ans[3]", "minValue": "ans[3]", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "ans[4]", "minValue": "ans[4]", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "ans[5]", "minValue": "ans[5]", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "\nFind the probability (to 3 decimal places) that two randomly selected {things}s in this survey are
\n7) both {somecat}: Probability = ? [[0]]
\n8) both {drk1}: Probability =? [[1]]
\n \n ", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "ans[6]", "minValue": "ans[6]", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "ans[7]", "minValue": "ans[7]", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "Given that a randomly selected {things} in this survey is {drk}, what is the probability that he:
\n9) is {somecat}: Probability = ? [[0]]
\n", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "ans[8]", "minValue": "ans[8]", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "extensions": ["stats"], "statement": "
A survey was conducted to obtain information on {this}. A random sample of {things}s gave :
\n{Cats} | \n{At[0]} | \n{At[1]} | \n{At[2]} | \nTotal | \n
{cat[0]} | \n{r[0][0]} | \n{r[0][1]} | \n{r[0][2]} | \n{sumr[0]} | \n
{cat[1]} | \n{r[1][0]} | \n{r[1][1]} | \n{r[1][2]} | \n{sumr[1]} | \n
{cat[2]} | \n{r[2][0]} | \n{r[2][1]} | \n{r[2][2]} | \n{sumr[2]} | \n
{cat[3]} | \n{r[3][0]} | \n{r[3][1]} | \n{r[3][2]} | \n{sumr[3]} | \n
Totals | \n{tc[0]} | \n{tc[1]} | \n{tc[2]} | \n\n {tot} \n | \n
Give all answers correct to 3 decimal places (not in fraction form).
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "preamble": {"css": "", "js": ""}, "variables": {"somecat": {"definition": "\n //name of category chosen using t\n cat[t]\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "somecat", "description": ""}, "ve": {"definition": "\n //sums across selected rows\n switch(v=1,sumr[0]+ sumr[1] ,v=2,sumr[0]+sumr[2],v=3,sumr[0]+sumr[3],v=4,sumr[1]+sumr[2],v=5,sumr[1]+sumr[3],sumr[2]+sumr[3])\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "ve", "description": ""}, "othercats": {"definition": "switch(t=0,cat[1]+\" or \"+ cat[2] ,t=1,cat[0]+\" or \"+cat[3],t=2,cat[0]+\" or \"+cat[1],t=3,cat[0]+\" or \"+cat[1],cat[0]+\" or \"+cat[2])", "templateType": "anything", "group": "Ungrouped variables", "name": "othercats", "description": ""}, "at": {"definition": "\n //column titles, the attributes\n [\"teetotal\",\"drinking 1-20 units/week\",\"drinking 21+ units/week\"]\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "at", "description": ""}, "ce1": {"definition": "\n //corresponding table entries given by w\n switch(w=1, r[0][0],w=2, r[0][1],w=3, r[0][2],w=4,r[1][0],w=5, r[1][1],r[1][2])\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "ce1", "description": ""}, "ans": {"definition": "\n //the answers bundled together. Index of answer corresponds to the order of the questions\n map(precround(x,3),x,[sumr[t]/n,tc[u]/n,ve/n,1-tc[u]/n,ce1/n,ce2/n,sumr[t]*(sumr[t]-1)/(n*(n-1)),tc[u1]*(tc[u1]-1)/(n*(n-1)),r[t][u]/tc[u],we2/tc[u]])\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "ans", "description": ""}, "n": {"definition": "\n //total number of observations\n random(1200..2300#2)\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "n", "description": ""}, "drk1": {"definition": "\n //the attribute chosen\n At[u1]\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "drk1", "description": ""}, "things": {"definition": "\n //kind of subjects\n \"male\"\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "things", "description": ""}, "u1": {"definition": "\n //another choice of attribute\n random(0..2)\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "u1", "description": ""}, "tot": {"definition": "\n //should be n, redundant\n sum(tc)\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "tot", "description": ""}, "catattrib2": {"definition": "\n //names of pairs of categories chosen using w1\n switch(w1=1,cat[2]+\" and \"+At[0],w1=2,cat[2]+\" and \"+At[1],w1=3,cat[2]+\" and \"+At[2],w1=4,cat[3]+\" and \"+At[0],w1=5,cat[3]+\" and \"+At[1],cat[3]+\" and \"+At[2])\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "catattrib2", "description": ""}, "cats": {"definition": "\n //Title of row\n \"Marital Status\"\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "cats", "description": ""}, "tc": {"definition": "\n //the column sums, attribute numbers. preordained, probably not a good idea\n [tc1,tc2,tc3]\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "tc", "description": ""}, "w1": {"definition": "\n //another category,attribute pair\n random(1..6)\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "w1", "description": ""}, "oneof": {"definition": "\n //names of pairs of categories chosen using v\n switch(v=1,cat[0]+\" or \"+ cat[1] ,v=2,cat[0]+\" or \"+cat[2],v=3,cat[0]+\" or \"+cat[3],v=4,cat[1]+\" or \"+cat[2],v=5,cat[1]+\" or \"+cat[3],cat[2]+\" or \"+cat[3])\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "oneof", "description": ""}, "tc2": {"definition": "\n //second attribute sum\n n-tc1-tc3\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "tc2", "description": ""}, "tc3": {"definition": "\n //third attribute sum\n round(n/random(6.5..7.5#0.1))\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "tc3", "description": ""}, "tc1": {"definition": "\n //first attribute sum\n round(n/random(2.5..3.5#0.1))\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "tc1", "description": ""}, "catattrib1": {"definition": "\n //names of pairs of categories chosen using w\n switch(w=1,cat[0]+\" and \"+At[0],w=2,cat[0]+\" and \"+At[1],w=3,cat[0]+\" and \"+At[2],w=4,cat[1]+\" and \"+At[0],w=5,cat[1]+\" and \"+At[1],cat[1]+\" and \"+At[2])\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "catattrib1", "description": ""}, "a": {"definition": "\n //assigning numbers (need to transpose to convert rows to columns)\n //0 in second entry adjusted by matrix r below using the norm function, so column sums the same\n [[round(tc1/random(7.5..8.5#0.1)),0,round(tc1/random(6.5..7.5#0.1)),round(tc1/random(19.5..20.5#0.1))],[round(tc2/random(3.5..4.5#0.1)),0,round(tc2/random(19.5..20.5#0.1)),round(tc2/random(19.5..20.5#0.1))],[round(tc3/random(2.5..3.5#0.1)),0,random(5..15),round(tc3/random(14.5..15.5#0.1))]]\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "drkpair": {"definition": "\n //names of attributes chosen using u\n switch(u=0,\"drinks alcohol\",u=1,At[0]+' or ' + At[2],At[0]+\" or \" +At[1])\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "drkpair", "description": ""}, "this": {"definition": "\n //what about\n \"alcohol consumption\"\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "this", "description": ""}, "cat": {"definition": "\n //Row categories\n ['single','married','divorced','widowed']\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "cat", "description": ""}, "we2": {"definition": "if(u=0, if(t=0,r[1][0]+r[2][0], if(t=1,r[0][0]+r[3][0], if(t=2,r[0][0]+r[1][0],r[0][0]+r[2][0]))),if(u=1, if(t=0,r[1][1]+r[2][1], if(t=1,r[0][1]+r[3][1], if(t=2,r[0][1]+r[1][1],r[0][1]+r[2][1]))),if(t=0,r[1][2]+r[2][2], if(t=1,r[0][2]+r[3][2], if(t=2,r[0][2]+r[1][2], r[0][2]+r[2][2])))))", "templateType": "anything", "group": "Ungrouped variables", "name": "we2", "description": ""}, "drk": {"definition": "\n //name of attribute chosen using u\n At[u]\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "drk", "description": ""}, "r": {"definition": "\n //uses the user defined function norm to complete the matrix columns so that the sums are tc\n transpose(matrix(map(norm(a[y],1,tc[y]),y,0..2)))\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "r", "description": ""}, "u": {"definition": "\n //used to choose a column attribute\n random(0..2)\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "u", "description": ""}, "t": {"definition": "\n //used to choose a row category\n random(0..3)\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "t", "description": ""}, "w": {"definition": "\n // category,attribute pair\n random(1..6)\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "w", "description": ""}, "v": {"definition": "\n //used to choose a pair of row categories randomly\n random(1..6)\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "v", "description": ""}, "sumr": {"definition": "\n //sum of rows\n map(sum(list(r[y])),y,0..3)\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "sumr", "description": ""}, "ce2": {"definition": "\n //corresponding table entries given by w1\n switch(w1=1, r[2][0],w1=2, r[2][1],w1=3, r[2][2],w1=4,r[3][0],w1=5, r[3][1],r[3][2])\n ", "templateType": "anything", "group": "Ungrouped variables", "name": "ce2", "description": ""}}, "metadata": {"description": "Basic data structures and maths/stats functionality given.
\nYou can configure the rest.
\nrebelmaths
", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Julie Crowley", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/113/"}]}]}], "contributors": [{"name": "Julie Crowley", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/113/"}]}