// Numbas version: finer_feedback_settings {"name": "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": [{"variable_groups": [], "statement": "\n
A survey was conducted to obtain information on {this}. A random sample of {things}s gave :
\n\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{tot} | \n
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.
", "notes": "\n \t\t29/12/2012:
\n \t\tAdded tags and description.
\n \t\tThis is easily configurable to other surveys by changing the variables used for labelling. Added the tag sc to denote this. Also added tag, table, as there is a table included.
\n \t\tThe column labels in the table need to be centred.
\n \t\tThe presentation and layout of the questions should be improved and made consistent.
\n \t\tThere is a user-defined function norm(a,x,n) which takes a numeric list a and changes the entry a[x] so that the sum of entries in a is n. Added the tag udf.
\n \t\tCalculations correct on testing.
\n \t\t"}, "showQuestionGroupNames": false, "tags": ["ACE2013", "checked2015", "MAS1403"], "ungrouped_variables": ["somecat", "ve", "othercats", "at", "ce1", "ans", "cat", "drk1", "things", "u1", "tot", "catattrib2", "cats", "tc", "w1", "oneof", "tc2", "tc3", "tc1", "catattrib1", "a", "drkpair", "this", "n", "we2", "drk", "r", "u", "t", "w", "v", "sumr", "ce2"], "parts": [{"gaps": [{"allowFractions": false, "marks": 1, "type": "numberentry", "maxValue": "ans[0]", "showPrecisionHint": false, "minValue": "ans[0]", "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}}, {"allowFractions": false, "marks": 1, "type": "numberentry", "maxValue": "ans[1]", "showPrecisionHint": false, "minValue": "ans[1]", "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}}, {"allowFractions": false, "marks": 1, "type": "numberentry", "maxValue": "ans[2]", "showPrecisionHint": false, "minValue": "ans[2]", "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}}, {"allowFractions": false, "marks": 1, "type": "numberentry", "maxValue": "ans[3]", "showPrecisionHint": false, "minValue": "ans[3]", "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}}, {"allowFractions": false, "marks": 1, "type": "numberentry", "maxValue": "ans[4]", "showPrecisionHint": false, "minValue": "ans[4]", "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}}, {"allowFractions": false, "marks": 1, "type": "numberentry", "maxValue": "ans[5]", "showPrecisionHint": false, "minValue": "ans[5]", "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}}], "marks": 0, "type": "gapfill", "prompt": "\nFind the following probabilities that a randomly chosen {things} involved in this survey:(Enter all probabilities to 3 decimal places).
\n1) is {somecat}: Probability =? [[0]]
\n2) is {drk}: Probability = ? [[1]]
\n3) is either {oneof}: Probability =? [[2]]
\n4) {drkpair}: Probability =? [[3]]
\n5) {catattrib1}: Probability =? [[4]]
\n6) {catattrib2}: Probability=? [[5]]
\n ", "showCorrectAnswer": true, "scripts": {}}, {"gaps": [{"allowFractions": false, "marks": 1, "type": "numberentry", "maxValue": "ans[6]", "showPrecisionHint": false, "minValue": "ans[6]", "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}}, {"allowFractions": false, "marks": 1, "type": "numberentry", "maxValue": "ans[7]", "showPrecisionHint": false, "minValue": "ans[7]", "showCorrectAnswer": true, "correctAnswerFraction": false, "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 ", "showCorrectAnswer": true, "scripts": {}}, {"gaps": [{"allowFractions": false, "marks": 1, "type": "numberentry", "maxValue": "ans[8]", "showPrecisionHint": false, "minValue": "ans[8]", "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}}, {"allowFractions": false, "marks": 1, "type": "numberentry", "maxValue": "ans[9]", "showPrecisionHint": false, "minValue": "ans[9]", "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}}], "marks": 0, "type": "gapfill", "prompt": "\nGiven that a randomly selected {things} in this survey is {drk}, what is the probability that he:
\n9) is {somecat}: Probability = ? [[0]]
\n10) is {othercats}: Probability =? [[1]]
\n\n ", "showCorrectAnswer": true, "scripts": {}}], "functions": {"norm": {"language": "javascript", "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.
\n10) 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": {}, "name": "Find probabilities from 2D frequency table,", "variablesTest": {"condition": "", "maxRuns": 100}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}