// Numbas version: exam_results_page_options {"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 \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}
\n \n ", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "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.

", "notes": "\n \t\t

29/12/2012:

\n \t\t

Added tags and description.

\n \t\t

This 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\t

The column labels in the table need to be centred.

\n \t\t

The presentation and layout of the questions should be improved and made consistent.

\n \t\t

There 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\t

Calculations 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": "\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 ", "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": "\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 ", "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": "\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 ", "showCorrectAnswer": true, "scripts": {}}], "functions": {"norm": {"language": "javascript", "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": {}, "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/"}]}