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

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

 

", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "\n

{sc[k]}

\n

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

\n

 

\n ", "tags": ["checked2015", "MAS1403"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

28/12/2012:

\n

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

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

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

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.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

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

"}, "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 ", "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/"}]}