// Numbas version: finer_feedback_settings {"name": "Elias Jakobus's copy of Find probabilities from 2D frequency table, ", "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;i1) The total number of {somecat} {things}s is $\\var{sumr[t]}$ hence the probability that a random {things} from this survey is {somecat} is $\\displaystyle \\frac{ \\var{sumr[t]}}{\\var{n}}=\\var{ans[0]}$ to 3 decimal places.

\n

 

\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.

\n

6) 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.

\n

8) 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.

\n

9) 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

10) Since there are $\\var{we2}$ {othercats} {things}s from the $\\var{tc[u]}$ {things}s that are {drk} the probability of selecting one  is $\\displaystyle \\frac{\\var{we2}}{\\var{tc[u]}}= \\var{ans[9]}$   to 3 decimal places.

\n ", "rulesets": {}, "parts": [{"prompt": "\n

Find the following probabilities that a randomly chosen {things} involved in this survey:(Enter all probabilities to 3 decimal places).

\n

1) is {somecat}: Probability =? [[0]]

\n

2) is {drk}:  Probability = ? [[1]]

\n

3) is either {oneof}: Probability =? [[2]]

\n

4) {drkpair}: Probability =? [[3]]

\n

5) {catattrib1}: Probability =? [[4]]

\n

6) {catattrib2}: Probability=? [[5]]

\n ", "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": "\n

Find the probability (to 3 decimal places) that two randomly selected {things}s in this survey are

\n

7) both {somecat}:  Probability = ? [[0]]

\n

8) both {drk1}: Probability =? [[1]]

\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": "\n

Given that a randomly selected {things} in this survey is {drk}, what is the probability that he:

\n

9) is {somecat}: Probability = ? [[0]]

\n

10) is {othercats}: Probability =? [[1]]

\n

 

\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}, {"allowFractions": false, "variableReplacements": [], "maxValue": "ans[9]", "minValue": "ans[9]", "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

 

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
{Cats}{At[0]}{At[1]}{At[2]}Total
{cat[0]}{r[0][0]}{r[0][1]}{r[0][2]}{sumr[0]}
{cat[1]}{r[1][0]}{r[1][1]}{r[1][2]}{sumr[1]}
{cat[2]}{r[2][0]}{r[2][1]}{r[2][2]}{sumr[2]}
{cat[3]}{r[3][0]}{r[3][1]}{r[3][2]}{sumr[3]}
Totals{tc[0]}{tc[1]}{tc[2]}{tot}
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"somecat": {"definition": "cat[t]", "templateType": "anything", "group": "Ungrouped variables", "name": "somecat", "description": ""}, "ve": {"definition": "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])", "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[2],cat[0]+\" or \"+cat[2])", "templateType": "anything", "group": "Ungrouped variables", "name": "othercats", "description": ""}, "at": {"definition": "[\"teetotal\",\"drinking 1-20 units/week\",\"drinking 21+ units/week\"]", "templateType": "anything", "group": "Ungrouped variables", "name": "at", "description": ""}, "ce1": {"definition": "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])", "templateType": "anything", "group": "Ungrouped variables", "name": "ce1", "description": ""}, "ans": {"definition": "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]])", "templateType": "anything", "group": "Ungrouped variables", "name": "ans", "description": ""}, "n": {"definition": "random(1200..2300#2)", "templateType": "anything", "group": "Ungrouped variables", "name": "n", "description": ""}, "drk1": {"definition": "At[u1]", "templateType": "anything", "group": "Ungrouped variables", "name": "drk1", "description": ""}, "things": {"definition": "\"male\"", "templateType": "anything", "group": "Ungrouped variables", "name": "things", "description": ""}, "u1": {"definition": "random(0..2)", "templateType": "anything", "group": "Ungrouped variables", "name": "u1", "description": ""}, "tot": {"definition": "sum(tc)", "templateType": "anything", "group": "Ungrouped variables", "name": "tot", "description": ""}, "catattrib2": {"definition": "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])", "templateType": "anything", "group": "Ungrouped variables", "name": "catattrib2", "description": ""}, "cats": {"definition": "\"Marital Status\"", "templateType": "anything", "group": "Ungrouped variables", "name": "cats", "description": ""}, "tc": {"definition": "[tc1,tc2,tc3]", "templateType": "anything", "group": "Ungrouped variables", "name": "tc", "description": ""}, "w1": {"definition": "random(1..6)", "templateType": "anything", "group": "Ungrouped variables", "name": "w1", "description": ""}, "oneof": {"definition": "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])", "templateType": "anything", "group": "Ungrouped variables", "name": "oneof", "description": ""}, "tc2": {"definition": "n-tc1-tc3", "templateType": "anything", "group": "Ungrouped variables", "name": "tc2", "description": ""}, "tc3": {"definition": "round(n/random(6.5..7.5#0.1))", "templateType": "anything", "group": "Ungrouped variables", "name": "tc3", "description": ""}, "tc1": {"definition": "round(n/random(2.5..3.5#0.1))", "templateType": "anything", "group": "Ungrouped variables", "name": "tc1", "description": ""}, "catattrib1": {"definition": "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])", "templateType": "anything", "group": "Ungrouped variables", "name": "catattrib1", "description": ""}, "a": {"definition": "[[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))]]", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "drkpair": {"definition": "switch(u=0,\"drinks alcohol\",u=1,At[0]+' or ' + At[2],At[0]+\" or \" +At[1])", "templateType": "anything", "group": "Ungrouped variables", "name": "drkpair", "description": ""}, "this": {"definition": "\"alcohol consumption\"", "templateType": "anything", "group": "Ungrouped variables", "name": "this", "description": ""}, "cat": {"definition": "['single','married','divorced','widowed']", "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": "At[u]", "templateType": "anything", "group": "Ungrouped variables", "name": "drk", "description": ""}, "r": {"definition": "transpose(matrix(map(norm(a[y],1,tc[y]),y,0..2)))", "templateType": "anything", "group": "Ungrouped variables", "name": "r", "description": ""}, "u": {"definition": "random(0..2)", "templateType": "anything", "group": "Ungrouped variables", "name": "u", "description": ""}, "t": {"definition": "random(0..3)", "templateType": "anything", "group": "Ungrouped variables", "name": "t", "description": ""}, "w": {"definition": "random(1..6)", "templateType": "anything", "group": "Ungrouped variables", "name": "w", "description": ""}, "v": {"definition": "random(1..6)", "templateType": "anything", "group": "Ungrouped variables", "name": "v", "description": ""}, "sumr": {"definition": "map(sum(list(r[y])),y,0..3)", "templateType": "anything", "group": "Ungrouped variables", "name": "sumr", "description": ""}, "ce2": {"definition": "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])", "templateType": "anything", "group": "Ungrouped variables", "name": "ce2", "description": ""}}, "metadata": {"description": "

Finding probabilities from a survey giving a table of data on the alcohol consumption of males. This can be easily adapted to data from other types of surveys.

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Elias Jakobus Willemse", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/846/"}]}]}], "contributors": [{"name": "Elias Jakobus Willemse", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/846/"}]}