// Numbas version: exam_results_page_options {"name": "Calculate probabilities from 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": [], "variables": {"q": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2", "description": "", "name": "q"}, "a0": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1000..4000#1000)", "description": "", "name": "a0"}, "ans2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((thismany-sum(n[0..v+1]))/thismany,2)", "description": "", "name": "ans2"}, "ans3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((n[1]+n[2])/thismany,2)", "description": "", "name": "ans3"}, "thismany": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(300..1000#100)", "description": "", "name": "thismany"}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round(thismany/random(3,6))", "description": "", "name": "n1"}, "sc": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['A bank made '+{thismany}+' car loans last year. The amounts were as follows (\u00a3):']", "description": "", "name": "sc"}, "b0": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1000..3000#1000)", "description": "", "name": "b0"}, "data": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\n[[0,a[0]-1,n[0]],\n [a[0],a[1]-1,n[1]],\n [a[1],a[2]-1,n[2]],\n [a[2],'plus',n[3]]]\n \n\n\n\n", "description": "", "name": "data"}, "n0": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round(thismany/random(15,25))", "description": "", "name": "n0"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0..abs(a)-1)", "description": "", "name": "t"}, "ans1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sum(n[0..t+1])/thismany,2)", "description": "", "name": "ans1"}, "n3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round(thismany/random(11,14))", "description": "", "name": "n3"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0..abs(sc)-1)", "description": "", "name": "k"}, "o1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "a[v]", "description": "", "name": "o1"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0..abs(a)-1 except t)", "description": "", "name": "v"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[n0,n1,thismany-n0-n1-n3,n3]", "description": "", "name": "n"}, "u1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "a[t]", "description": "", "name": "u1"}, "a": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[a0,a0+b0,a0+2*b0]", "description": "", "name": "a"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0", "description": "", "name": "p"}}, "ungrouped_variables": ["a", "sc", "p", "ans1", "k", "ans3", "u1", "thismany", "n", "q", "a0", "b0", "t", "v", "n0", "n1", "n3", "data", "ans2", "o1"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "name": "Calculate probabilities from frequency table", "functions": {"accumdisp": {"type": "string", "language": "jme", "definition": "if(k=0,'$\\\\var{a[0]}$','$\\\\var{a[0]}$ + '+accumdisp(a[1..abs(a)],k-1))", "parameters": [["a", "list"], ["k", "number"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ans1", "minValue": "ans1", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ans2", "minValue": "ans2", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ans3", "minValue": "ans3", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n

One of these loans is sampled randomly for review by the bank. What is the probability that it is :

\n

a) Under £$\\var{u1}$?   Probability = ? [[0]]  (answer to 2 decimal places).

\n

b) Over £$\\var{o1-1}$?     Probability = ? [[1]]  (answer to 2 decimal places).

\n

c) Between £$\\var{a[p]}$ and £$\\var{a[q]-1}$?    Probability = ? [[2]] (answer to 2 decimal places).

\n

 

\n

 

\n \n\n \n", "showCorrectAnswer": true, "marks": 0}], "statement": "\n

{sc[k]}

\n

{table(data,['  From','  To', '  Loans Made'])}

\n

 

\n \n\n \n", "tags": ["ACC1012", "acc1012", "checked2015", "probability", "Probability", "statistics", "udf"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n\t\t \t\t \t\t

28/12/2012:

\n\t\t \t\t \t\t

Using the inbuilt table function for now. This needs to be changed - either to direct input of an html table or improving the table function e.g. adding borders etc.

\n\t\t \t\t \t\t

The udf accumdisp(a,t) outputs a string of the form a[0]+a[1]+..a[t-1]  - useful to show in the solution the elements of the list we are summing over.

\n\t\t \t\t \t\t

There is a scenario variable sk, which is intended to be the beginning of a list of possible randomised scenarios. Probably best if this included other text based string variables (e.g. car loans could be the value of such a variable).

\n\t\t \t\t \t\t

Easy to make this have a variable number of ranges of loans. Only need to pay some attention to the creation of the list n giving the number of loans in each range - need to make that sensible.

\n\t\t \t\t \n\t\t \n\t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Simple probability question. Counting number of occurrences of an event in a sample space with given size and finding the probability of the event.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "\n

a) The number of loans less than £$\\var{u1}$ is $\\var{accumdisp(n,t)}=\\var{sum(n[0..t+1])}$

\n

Since there are $\\var{thismany}$ loans the probability of choosing one of these loans is  $\\displaystyle \\frac{\\var{sum(n[0..t+1])}}{\\var{thismany}}=\\var{ans1}$ to 2 decimal places.

\n

b) The number of loans greater than £$\\var{o1}$ is $\\var{accumdisp(n[v+1..abs(n)],abs(n)-v-2)}=\\var{sum(n[v+1..abs(n)])}$.

\n

Since there are $\\var{thismany}$ loans the probability of choosing one of these loans is  $\\displaystyle \\frac{\\var{sum(n[v+1..abs(n)])}}{\\var{thismany}}=\\var{ans2}$ to 2 decimal places.

\n

c) There are $\\var{accumdisp(n[p+1..q+1],q-p-1)}=\\var{sum(n[p+1..q+1])}$ loans between  £$\\var{a[p]}$ and £$\\var{a[q]-1}$.

\n

Hence the probability of selecting one of these loans in this range for review is $\\displaystyle \\frac{\\var{sum(n[p+1..q+1])}}{\\var{thismany}}=\\var{ans3}$ to 2 decimal places.

\n \n\n \n", "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}