// Numbas version: finer_feedback_settings {"name": "Statistical Analysis of Production", "extensions": ["stats", "jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Statistical Analysis of Production", "tags": [], "metadata": {"description": "", "licence": "None specified"}, "statement": "
The data below corresponds to energy consumption (kWh) and units of production (tonnes) for a particular factory as it runs over a 10 week period.
\nCopy the data from the table into (Microsoft Excel or similar) and plot the trendline as seen in the graph below.
\n\n| Week | \nProduction (tonnes) | \nEnergy (kWh) | \n
| 1 | \n{r1[0]} | \n{r2[0]} | \n
| 2 | \n{r1[1]} | \n{r2[1]} | \n
| 3 | \n{r1[2]} | \n{r2[2]} | \n
| 4 | \n{r1[3]} | \n{r2[3]} | \n
| 5 | \n{r1[4]} | \n{r2[4]} | \n
| 6 | \n{r1[5]} | \n{r2[5]} | \n
| 7 | \n{r1[6]} | \n{r2[6]} | \n
| 8 | \n{r1[7]} | \n{r2[7]} | \n
| 9 | \n{r1[8]} | \n{r2[8]} | \n
| 10 | \n{r1[9]} | \n{r2[9]} | \n
| Energy (kWh) | \n{drawgraph()} | \n
| \n | Production (tonnes) | \n
How much energy, in kWh, will likely be needed to produce {rand_units_of_product} tonnes of product?
\nEquation of a straight line: y = mx+c
\nWhere m is the gradient of the trendline and c is the y axis intercept.
\n\n
m = {precround(m_hat,3)}, c = {precround(c_hat,3)}
\nEnergy = {precround(m_hat,3)} x {rand_units_of_product} + {precround(c_hat,3)}
\nEnergy = {precround(energy_required,3)}kWh
\n\n\n
If the factory is using {rand_units_of_energy}kWh of energy, estimate how many tonnes of product are being produced.
\nEquation of a straight line: y = mx+c
\ny is the energy usage, x is the factory production.
\n\nStep 1, rearrange the equation.
\n(y-c)/m = x
\n\nStep 2, input values.
\n({rand_units_of_energy}-{precround(c_hat,3)})/{precround(m_hat,3)} = x
\nx = {product_tonnes_produced} tonnes
", "rulesets": {}, "extensions": ["jsxgraph", "stats"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"r1": {"name": "r1", "group": "Ungrouped variables", "definition": "repeat(abs(round(normalsample(1200,600))),n)", "description": "", "templateType": "anything", "can_override": false}, "m": {"name": "m", "group": "Ungrouped variables", "definition": "random(10..20)", "description": "", "templateType": "anything", "can_override": false}, "c": {"name": "c", "group": "Ungrouped variables", "definition": "random(10000..100000#1000)", "description": "", "templateType": "anything", "can_override": false}, "r2": {"name": "r2", "group": "Ungrouped variables", "definition": "map(round(c+m*x+random(-5000..5000)),x,r1)", "description": "", "templateType": "anything", "can_override": false}, "spxy": {"name": "spxy", "group": "Calculate line of best fit", "definition": "sxy-t[0]*t[1]/n\n\n", "description": "", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "10", "description": "", "templateType": "number", "can_override": false}, "c_hat": {"name": "c_hat", "group": "Calculate line of best fit", "definition": "1/n*(t[1]-spxy/ss[0]*t[0])", "description": "", "templateType": "anything", "can_override": false}, "m_hat": {"name": "m_hat", "group": "Calculate line of best fit", "definition": "spxy/ss[0]", "description": "", "templateType": "anything", "can_override": false}, "ss": {"name": "ss", "group": "Calculate line of best fit", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "description": "", "templateType": "anything", "can_override": false}, "res": {"name": "res", "group": "Calculate line of best fit", "definition": "map(r2[x]-(c_hat+m_hat*r1[x]),x,0..n-1)", "description": "", "templateType": "anything", "can_override": false}, "ssq": {"name": "ssq", "group": "Calculate line of best fit", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "description": "", "templateType": "anything", "can_override": false}, "sxy": {"name": "sxy", "group": "Calculate line of best fit", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "description": "", "templateType": "anything", "can_override": false}, "t": {"name": "t", "group": "Calculate line of best fit", "definition": "[sum(r1),sum(r2)]", "description": "", "templateType": "anything", "can_override": false}, "minx": {"name": "minx", "group": "Plotting", "definition": "min(r1)", "description": "", "templateType": "anything", "can_override": false}, "miny": {"name": "miny", "group": "Plotting", "definition": "min(r2)", "description": "", "templateType": "anything", "can_override": false}, "maxx": {"name": "maxx", "group": "Plotting", "definition": "max(r1)", "description": "", "templateType": "anything", "can_override": false}, "maxy": {"name": "maxy", "group": "Plotting", "definition": "max(r2)", "description": "", "templateType": "anything", "can_override": false}, "regy1": {"name": "regy1", "group": "Plotting", "definition": "m_hat*min(r1)+c_hat", "description": "", "templateType": "anything", "can_override": false}, "regy2": {"name": "regy2", "group": "Plotting", "definition": "m_hat*max(r1)+c_hat", "description": "", "templateType": "anything", "can_override": false}, "rand_units_of_product": {"name": "rand_units_of_product", "group": "question variables", "definition": "abs(round(normalsample(1200,600)))", "description": "", "templateType": "anything", "can_override": false}, "rand_units_of_energy": {"name": "rand_units_of_energy", "group": "question variables", "definition": "round(c+m*abs(round(normalsample(1200,600)))+random(-5000..5000))", "description": "", "templateType": "anything", "can_override": false}, "energy_required": {"name": "energy_required", "group": "question variables", "definition": "(m_hat*rand_units_of_product)+c_hat", "description": "", "templateType": "anything", "can_override": false}, "product_tonnes_produced": {"name": "product_tonnes_produced", "group": "question variables", "definition": "(rand_units_of_energy-c_hat)/m_hat", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["r1", "m", "c", "r2", "n"], "variable_groups": [{"name": "Calculate line of best fit", "variables": ["spxy", "c_hat", "m_hat", "ss", "res", "ssq", "sxy", "t"]}, {"name": "Plotting", "variables": ["minx", "miny", "maxx", "maxy", "regy1", "regy2"]}, {"name": "question variables", "variables": ["rand_units_of_product", "rand_units_of_energy", "energy_required", "product_tonnes_produced"]}], "functions": {"drawgraph": {"parameters": [], "type": "html", "language": "javascript", "definition": "var miny = Numbas.jme.unwrapValue(scope.variables.miny);\nvar maxy = Numbas.jme.unwrapValue(scope.variables.maxy);\nvar minx = Numbas.jme.unwrapValue(scope.variables.minx);\nvar maxx = Numbas.jme.unwrapValue(scope.variables.maxx);\nvar r1 = Numbas.jme.unwrapValue(scope.variables.r1);\nvar r2 = Numbas.jme.unwrapValue(scope.variables.r2);\n\nvar m = Numbas.jme.unwrapValue(scope.variables.m_hat);\nvar c = Numbas.jme.unwrapValue(scope.variables.c_hat);\n\nvar regy1 = Numbas.jme.unwrapValue(scope.variables.regy1);\nvar regy2 = Numbas.jme.unwrapValue(scope.variables.regy2);\n\n// Ensure a reasonable margin for visibility\nvar x_margin = (maxx - minx) * 0.1; // 10% margin\nvar y_margin = (maxy - miny) * 0.1;\n\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',\n{\n boundingBox: [minx - x_margin, maxy + y_margin, maxx + x_margin, miny - y_margin],\n axis: false,\n showNavigation: true,\n grid: true,\n zoomX: true,\n zoomY:true,\n pan: {\n enabled: true, // Allow panning\n needShift: false, // No need to hold Shift to pan\n needTwoFingers: false // No need for two fingers on touch devices\n }\n \n});\n\nvar brd = div.board; \n\n// Ensure axes extend fully\nvar xaxis = brd.create('axis', [[minx - x_margin, 0], [maxx + x_margin, 0]], { fixed: true });\nvar yaxis = brd.create('axis', [[0, miny - y_margin], [0, maxy + y_margin]], { fixed: true });\n\n// Regression line\nvar li1 = brd.create('line', [[minx, regy1], [maxx, regy2]], { fixed: true, withLabel: false });\n\n// Plot points\nfor (let i = 0; i < Math.min(10, r1.length, r2.length); i++) {\n brd.create('point', [r1[i], r2[i]], { visible: true, withLabel: false, fixed: true });\n}\n\nreturn div;"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Predict the fixed energy cost in kWh to run the factory at idle (i.e. no production).
\nHint: Calculate the y-axis intercept of the trendline.
", "minValue": "c_hat", "maxValue": "c_hat", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": 0, "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": true, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "How much extra energy, in kWh, is needed to produce one additional tonne of product?
\nHint: Calculate the gradient of the trendline.
\n", "minValue": "m_hat", "maxValue": "m_hat", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": 0, "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": true, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "How much energy, in kWh, will likely be needed to produce {rand_units_of_product} tonnes of product?
", "minValue": "energy_required", "maxValue": "energy_required", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": 0, "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": true, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "If the factory is using {rand_units_of_energy}kWh of energy, estimate how many tonnes of product are being produced.
", "minValue": "product_tonnes_produced", "maxValue": "product_tonnes_produced", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": 0, "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": true, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Simon Stuttaford", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/26443/"}], "resources": []}]}], "contributors": [{"name": "Simon Stuttaford", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/26443/"}]}