// 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": [], "statement": "\n
{sc[k]}
\n{table(data,[' From',' To', ' Loans Made'])}
\n\n ", "metadata": {"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.
", "notes": "28/12/2012:
\nUsing 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.
\nThe 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.
\nThere 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).
\nEasy 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.
"}, "showQuestionGroupNames": false, "tags": ["checked2015", "MAS1403"], "ungrouped_variables": ["a", "sc", "p", "ans1", "k", "ans3", "u1", "thismany", "n", "q", "a0", "b0", "t", "v", "n0", "n1", "n3", "data", "ans2", "o1"], "parts": [{"variableReplacementStrategy": "originalfirst", "marks": 0, "prompt": "One of these loans is sampled randomly for review by the bank. What is the probability that it is :
\na) Under £$\\var{u1}$? Probability = ? [[0]] (answer to 2 decimal places).
\nb) Over £$\\var{o1-1}$? Probability = ? [[1]] (answer to 2 decimal places).
\nc) Between £$\\var{a[p]}$ and £$\\var{a[q]-1}$? Probability = ? [[2]] (answer to 2 decimal places).
\n\n
", "type": "gapfill", "gaps": [{"variableReplacementStrategy": "originalfirst", "marks": 1, "type": "numberentry", "maxValue": "ans1", "showPrecisionHint": false, "minValue": "ans1", "allowFractions": false, "showCorrectAnswer": false, "correctAnswerFraction": false, "variableReplacements": [], "scripts": {}}, {"variableReplacementStrategy": "originalfirst", "marks": 1, "type": "numberentry", "maxValue": "ans2", "showPrecisionHint": false, "minValue": "ans2", "allowFractions": false, "showCorrectAnswer": true, "correctAnswerFraction": false, "variableReplacements": [], "scripts": {}}, {"variableReplacementStrategy": "originalfirst", "marks": 1, "type": "numberentry", "maxValue": "ans3", "showPrecisionHint": false, "minValue": "ans3", "allowFractions": false, "showCorrectAnswer": true, "correctAnswerFraction": false, "variableReplacements": [], "scripts": {}}], "showCorrectAnswer": true, "variableReplacements": [], "scripts": {}}], "functions": {"accumdisp": {"parameters": [["a", "list"], ["k", "number"]], "definition": "if(k=0,'$\\\\var{a[0]}$','$\\\\var{a[0]}$ + '+accumdisp(a[1..abs(a)],k-1))", "type": "string", "language": "jme"}}, "preamble": {"css": "", "js": ""}, "variables": {"k": {"group": "Ungrouped variables", "description": "", "definition": "random(0..abs(sc)-1)", "name": "k", "templateType": "anything"}, "u1": {"group": "Ungrouped variables", "description": "", "definition": "a[t]", "name": "u1", "templateType": "anything"}, "a0": {"group": "Ungrouped variables", "description": "", "definition": "random(1000..4000#1000)", "name": "a0", "templateType": "anything"}, "v": {"group": "Ungrouped variables", "description": "", "definition": "random(0..abs(a)-1 except t)", "name": "v", "templateType": "anything"}, "p": {"group": "Ungrouped variables", "description": "", "definition": "0", "name": "p", "templateType": "anything"}, "n1": {"group": "Ungrouped variables", "description": "", "definition": "round(thismany/random(3,6))", "name": "n1", "templateType": "anything"}, "ans3": {"group": "Ungrouped variables", "description": "", "definition": "precround((n[1]+n[2])/thismany,2)", "name": "ans3", "templateType": "anything"}, "a": {"group": "Ungrouped variables", "description": "", "definition": "[a0,a0+b0,a0+2*b0]", "name": "a", "templateType": "anything"}, "q": {"group": "Ungrouped variables", "description": "", "definition": "2", "name": "q", "templateType": "anything"}, "n0": {"group": "Ungrouped variables", "description": "", "definition": "round(thismany/random(15,25))", "name": "n0", "templateType": "anything"}, "sc": {"group": "Ungrouped variables", "description": "", "definition": "['A bank made '+{thismany}+' car loans last year. The amounts were as follows (\u00a3):']", "name": "sc", "templateType": "anything"}, "ans1": {"group": "Ungrouped variables", "description": "", "definition": "precround(sum(n[0..t+1])/thismany,2)", "name": "ans1", "templateType": "anything"}, "o1": {"group": "Ungrouped variables", "description": "", "definition": "a[v]", "name": "o1", "templateType": "anything"}, "t": {"group": "Ungrouped variables", "description": "", "definition": "random(0..abs(a)-1)", "name": "t", "templateType": "anything"}, "data": {"group": "Ungrouped variables", "description": "", "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", "templateType": "anything"}, "n3": {"group": "Ungrouped variables", "description": "", "definition": "round(thismany/random(11,14))", "name": "n3", "templateType": "anything"}, "thismany": {"group": "Ungrouped variables", "description": "", "definition": "random(300..1000#100)", "name": "thismany", "templateType": "anything"}, "ans2": {"group": "Ungrouped variables", "description": "", "definition": "precround((thismany-sum(n[0..v+1]))/thismany,2)", "name": "ans2", "templateType": "anything"}, "b0": {"group": "Ungrouped variables", "description": "", "definition": "random(1000..3000#1000)", "name": "b0", "templateType": "anything"}, "n": {"group": "Ungrouped variables", "description": "", "definition": "[n0,n1,thismany-n0-n1-n3,n3]", "name": "n", "templateType": "anything"}}, "question_groups": [{"pickQuestions": 0, "pickingStrategy": "all-ordered", "questions": [], "name": ""}], "type": "question", "advice": "\n
a) The number of loans less than £$\\var{u1}$ is $\\var{accumdisp(n,t)}=\\var{sum(n[0..t+1])}$
\nSince 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.
\nb) 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)])}$.
\nSince 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.
\nc) 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}$.
\nHence 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 ", "rulesets": {}, "name": "Calculate probabilities from 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/"}]}