// Numbas version: exam_results_page_options {"name": "Lois's copy of Numerical reasoning - average salary", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {"commanumber": {"definition": "var parts=n.toString().split(\".\");\n if(parts[1] && parts[1].length<2) {\n parts[1]+='0';\n }\n return parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\") + (parts[1] ? \".\" + parts[1] : \"\");", "type": "string", "language": "javascript", "parameters": [["n", "number"]]}}, "ungrouped_variables": ["salary", "salary1", "salary0", "salary3", "salary2", "average", "per", "per3", "per2", "per1", "per0", "per0dec", "per1dec", "per2dec", "per3dec", "department"], "name": "Lois's copy of Numerical reasoning - average salary", "tags": [], "preamble": {"css": "", "js": ""}, "advice": "

We need to calculate a weighted mean.

\n

We can do this by multiplying each salary by the proportion of people who earn it and then adding these amounts.

\n

$£ \\var{commanumber(salary0)} \\times \\var{per0}\\% = £\\var{commanumber(salary0)} \\times \\var{per0dec} =£\\var{salary0*per0/100}. $

\n

$£ \\var{commanumber(salary1)} \\times \\var{per1}\\% = £\\var{commanumber(salary1)} \\times \\var{per1dec} =£\\var{salary1*per1/100}. $

\n

$£ \\var{commanumber(salary2)} \\times \\var{per2}\\% = £\\var{commanumber(salary2)} \\times \\var{per2dec} =£\\var{salary2*per2/100}. $

\n

$£ \\var{commanumber(salary3)} \\times \\var{per3}\\% = £\\var{commanumber(salary3)} \\times \\var{per3dec} =£\\var{salary3*per3/100}. $

\n

\n

If we add these we get £{commanumber(average)}.

\n

(For a weighted mean we need to divide the total  by the sum of the weights, but in this case the weights add to 1.)

\n

For more information about calculating a mean from a frequency table see the Statstutor leaflet at http://www.statstutor.ac.uk/resources/uploaded/meangroupeddata.pdf

\n

", "rulesets": {}, "parts": [{"prompt": "

What is the mean salary of the people working in {department}?

\n

£ [[0]]

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "average", "minValue": "average", "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "correctAnswerStyle": "plain"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "extensions": [], "statement": "

In a {department} department {per0}% of the staff have a salary of £{commanumber(salary0)}, {per1}% a salary of £{commanumber(salary1)}, {per2}% a salary of £{commanumber(salary2)}, and {per3}% a salary of £{commanumber(salary3)}.

", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"salary": {"definition": "shuffle([salary0,salary1,salary2,salary3])", "templateType": "anything", "group": "Ungrouped variables", "name": "salary", "description": ""}, "per1dec": {"definition": "per1/100", "templateType": "anything", "group": "Ungrouped variables", "name": "per1dec", "description": ""}, "per3dec": {"definition": "per3/100", "templateType": "anything", "group": "Ungrouped variables", "name": "per3dec", "description": ""}, "salary1": {"definition": "random(15000..50000#5000 except salary0)", "templateType": "anything", "group": "Ungrouped variables", "name": "salary1", "description": ""}, "salary0": {"definition": "random(15000..50000#5000)", "templateType": "anything", "group": "Ungrouped variables", "name": "salary0", "description": ""}, "salary3": {"definition": "random(15000..50000#5000 except [salary0,salary1,salary2])", "templateType": "anything", "group": "Ungrouped variables", "name": "salary3", "description": ""}, "salary2": {"definition": "random(15000..50000#5000 except [salary0,salary1])", "templateType": "anything", "group": "Ungrouped variables", "name": "salary2", "description": ""}, "average": {"definition": "(per0*salary0+per1*salary1+per2*salary2+per3*salary3)/100", "templateType": "anything", "group": "Ungrouped variables", "name": "average", "description": ""}, "department": {"definition": "random( \"marketing\", \"sales\",\"advertsing\", \"accounting\")", "templateType": "anything", "group": "Ungrouped variables", "name": "department", "description": ""}, "per": {"definition": "shuffle([per0,per1,per2,per3])", "templateType": "anything", "group": "Ungrouped variables", "name": "per", "description": ""}, "per3": {"definition": "100-per0-per1-per2", "templateType": "anything", "group": "Ungrouped variables", "name": "per3", "description": ""}, "per2": {"definition": "random(10..min(50,90-per0-per1)#10)", "templateType": "anything", "group": "Ungrouped variables", "name": "per2", "description": ""}, "per1": {"definition": "random(10..min(50,80-per0)#10)", "templateType": "anything", "group": "Ungrouped variables", "name": "per1", "description": ""}, "per0": {"definition": "random(10..50#10)", "templateType": "anything", "group": "Ungrouped variables", "name": "per0", "description": ""}, "per0dec": {"definition": "per0/100\n", "templateType": "anything", "group": "Ungrouped variables", "name": "per0dec", "description": ""}, "per2dec": {"definition": "per2/100", "templateType": "anything", "group": "Ungrouped variables", "name": "per2dec", "description": ""}}, "metadata": {"description": "

Compute the weighted average salary in a department, given four salary levels and the percentages of staff earning them.

\n

(Added to calculator test.)

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "contributors": [{"name": "Lois Rollings", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/326/"}]}]}], "contributors": [{"name": "Lois Rollings", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/326/"}]}