// Numbas version: finer_feedback_settings {"name": "Descriptive Statistics (draft)", "metadata": {"description": "", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "duration": 0, "percentPass": 0, "showQuestionGroupNames": false, "shuffleQuestionGroups": false, "showstudentname": true, "question_groups": [{"name": "Group", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", "", "", "", "", ""], "variable_overrides": [[], [], [], [], [], []], "questions": [{"name": "Types of Data", "extensions": [], "custom_part_types": [], "resources": ["question-resources/rba-chart.png"], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "feedback": {"showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showpartfeedbackmessageswhen": "always", "allowrevealanswer": true, "showexpectedanswerswhen": "inreview", "showadvicewhen": "inreview"}, "contributors": [{"name": "Fern Gossow", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/38158/"}], "tags": [], "metadata": {"description": "", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": [], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "prompt": "

When analysing data of any sort, we can use both numeric and visual tools to help us look for underlying patterns and features.

\n

{image('resources/question-resources/rba-chart.png',20)}

\n

The tools we can use depend on the types of data we are analysing. Overall, there are three main classes.

\n\n

\n

Classify the following examples.

\n

[[0]]

\n

", "gaps": [{"type": "m_n_x", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "minAnswers": 0, "maxAnswers": 0, "shuffleChoices": false, "shuffleAnswers": false, "displayType": "radiogroup", "warningType": "none", "showCellAnswerState": true, "markingMethod": "sum ticked cells", "interpretedAnswerForm": "list of list of boolean", "choices": ["number of vehicles manufactured", "type of vehicle manufactured", "employee country of origin", "employee socioeconomic status
(low/middle/high)", "union participation rate", "educational attainment
(high school/undergrad/postgrad)", "unemployment rate", "industry of employment"], "matrix": [["1", 0, 0], [0, "1", 0], [0, "1", 0], [0, 0, "1"], ["1", 0, 0], [0, 0, "1"], ["1", 0, 0], [0, "1", 0]], "layout": {"type": "all", "expression": ""}, "answers": ["Numeric", "Categorical", "Ordinal"], "choicesHeader": "", "answersHeader": ""}], "sortAnswers": false, "inlineCorrectAnswer": true}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "showAllParts": false}, {"name": "Bar Charts", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "feedback": {"showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showpartfeedbackmessageswhen": "always", "allowrevealanswer": true, "showexpectedanswerswhen": "inreview", "showadvicewhen": "inreview"}, "contributors": [{"name": "Fern Gossow", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/38158/"}], "tags": [], "metadata": {"description": "", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": [], "variable_groups": [], "functions": {"barchart": {"parameters": [], "type": "html", "language": "javascript", "definition": "// Bar chart for G7 countries by GDP\n// Numbers shown when hovering over a bar\n\nvar div = Numbas.extensions.jsxgraph.makeBoard(\"500px\",\"300px\", {\n axis: true,\n boundingBox: [-1.2,35,8,-2],\n defaultAxes: {\n x: {highlight: false, lastArrow: 0, ticks: {visible: false}},\n y: {highlight: false, ticks: {majorHeight: 5, minorHeight: 0}}\n },\n pan: {enabled: false}, zoom: {enabled: false}\n});\n \nvar board = div.board;\n\nconst COUNTRIES = [\"Canada\", \"France\", \"Germany\", \"Italy\", \"Japan\", \"UK\", \"USA\"];\nconst GDP = [2.32,3.38,5.12,2.55,4.45,4.01,30.86];\n\nvar bars = [];\nfor (var i=0;iThe first chart we will examine is a bar chart, which shows the GDP of the G7 countries in 2025. Hover over each bar to see the exact value.

\n

{barchart()}

\n

According to the chart, the GDP of Japan in 2025 was \\$[[2]] trillion USD.

\n

The $x$-axis represents the country, which is a [[0]] variable. The $y$-axis represents the GDP in trillions of USD, which is a [[1]] variable. We call this chart bivariate, because each data point (or observation) combines two variables.

\n
\n

There are a few statistics we can calculate from this data. The mean is the average GDP value across all countries. The mean is usually denoted by the Greek letter $\\mu$ (mu), and calculated as

\n

$$\\mu=\\frac{\\sum_C\\text{GDP of country }C}{\\text{number of countries}}$$

\n

where the Greek capital letter $\\Sigma$ (Sigma) means we take the sum over all countries $C$.

\n

The total GDP of all countries above was $\\$52.69$ trillion USD and there are [[3]] countries in total, so the average GDP was $\\mu=\\$$ [[4]] trillion USD (answer to 2 decimal places).

\n
\n

The variance measures the spread of the data, or how far away the observations tend to be from the mean. We denote the variance by $\\sigma^2$ using the Greek letter $\\sigma$ (sigma) and its formula is

\n

$$\\sigma^2=\\frac{\\sum_C(\\text{GDP}_C-\\mu)^2}{\\text{number of countries}}$$

\n

where $\\text{GDP}_C$ is the GDP of each country $C$ in the sum and $\\mu$ is the mean above.

\n

For example, $\\text{GDP}_\\text{UK}=4.01$, so $(\\text{GDP}_\\text{UK}-\\mu)^2=$ [[5]].

\n

Making this calculation for every country and taking the average gives a variance of $\\sigma^2=91.6$.

\n

The units for the variance are now $(\\$/\\text{country})^2$ because of the squaring involved, so it is more usual to report the standard deviation $\\sigma$, which is equal to the square root of the variance. Using the above value for the variance, the standard deviation is $\\sigma=$ [[6]].

", "gaps": [{"type": "1_n_2", "useCustomName": true, "customName": "type1", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["numeric", "categorical", "ordinal"], "matrix": [0, "1", 0], "distractors": ["", "", ""]}, {"type": "1_n_2", "useCustomName": true, "customName": "type2", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["numeric", "categorical", "ordinal"], "matrix": ["1", "0", 0], "distractors": ["", "", ""]}, {"type": "numberentry", "useCustomName": true, "customName": "gdp", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "4.45-0.3", "maxValue": "4.45+0.3", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "number", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "7", "maxValue": "7", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "mu", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "52.69/7-0.01", "maxValue": "52.69/7+0.01", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "d^2", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "12.32-0.1", "maxValue": "12.32+0.1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "stdev", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "sqrt(91.6)-0.1", "maxValue": "sqrt(91.6)+0.1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false, "inlineCorrectAnswer": true}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "showAllParts": false}, {"name": "Boxplots", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "feedback": {"showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showpartfeedbackmessageswhen": "always", "allowrevealanswer": true, "showexpectedanswerswhen": "inreview", "showadvicewhen": "inreview"}, "contributors": [{"name": "Fern Gossow", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/38158/"}], "tags": [], "metadata": {"description": "", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": [], "variable_groups": [], "functions": {"boxplot": {"parameters": [], "type": "html", "language": "javascript", "definition": "const div = Numbas.extensions.jsxgraph.makeBoard('600px', '120px', {\n boundingBox: [900,1.5,3500,-0.8],\n axis: true,\n defaultAxes: {\n y: {highlight: false, lastArrow: 0, \n ticks: {visible: false}},\n x: {highlight: false, \n ticks: {majorHeight: 5, minorHeight: 5,\n minorTicks: 3\n }}\n },\n pan: {enabled: false}, zoom: {enabled: false}\n});\n\nconst board = div.board;\n\nconst LGA = [\"Fairfield\", \"Canterbury-Bankstown\", \"Cumberland\", \"Campbelltown\", \"Blue Mountains\", \"Liverpool\", \"Burwood\", \"Penrith\", \"Bayside\", \"Hawkesbury\", \"Georges River\", \"Parramatta\", \"Ryde\", \"Strathfield\", \"Blacktown\", \"Wollondilly\", \"City of Sydney\", \"Sutherland Shire\", \"Randwick\", \"Inner West\", \"Camden\", \"Canada Bay\", \"Hornsby\", \"North Sydney\", \"Willoughby\", \"Northern Beaches\", \"Lane Cove\", \"The Hills Shire\", \"Waverley\", \"Mosman\", \"Hunters Hill\", \"Ku-ring-gai\", \"Woollahra\"];\nconst INC = [1390, 1556, 1678, 1700, 1756, 1819, 1867, 1903, 1959, 1980, 1991, 2051, 2098, 2105, 2107, 2151, 2212, 2288, 2305, 2340, 2353, 2371, 2417, 2524, 2556, 2592, 2801, 2831, 2854, 2892, 2998, 3038, 3192];\nconst YOFF = [0.42, -0.76, 0.13, -0.28, 0.91, -0.54, 0.67, -0.09, 0.35, -0.88, 0.58, -0.41, 0.04, 0.79, -0.63, 0.22, -0.17, 0.96, -0.48, 0.31, -0.71, 0.51, -0.02, 0.73, -0.36, 0.18, -0.95, 0.62, -0.24, 0.44, -0.57, 0.08, -0.81];\n\nconst initial = 18;\n\nvar special = board.create(\"point\", [\n INC[initial], 0.7 + 0.35*YOFF[initial]\n], {\n fixed: true,\n face: '<>',\n size: 8,\n highlight: false,\n showInfobox: false,\n fillColor: \"#8A68C8\",\n strokeWidth: 0,\n withLabel: false,\n fillOpacity: 0.4,\n visible: true\n})\n\nvar points = [];\nfor (var i=0; i',\n size: 4,\n highlight: false,\n showInfobox: false,\n fillColor: \"#3F61C4\",\n strokeWidth: 0,\n withLabel: false\n }))\n}\n\nvar lga_text = board.create(\"text\", [\n 934, -0.4, \"LGA: \" + LGA[initial]\n], {\n fixed: true, highlight: false,\n anchorY: \"top\"\n});\n\nvar income_text = board.create(\"text\", [\n 1800, -0.4, \"Weekly income: $\" + INC[initial]\n], {\n fixed: true, highlight: false,\n anchorY: \"top\"\n})\n\n\nvar boxplot = board.create('boxplot', [\n [1390, 1959, 2212, 2556, 3192], 0.7, 1\n], {\n fixed: true, highlight: false,\n dir: 'horizontal',\n layer: 12,\n strokeColor: \"#FF635D\",\n fillColor: \"#FF635D\",\n layer: 5\n})\n\nvar reference = board.create('text', [\n 3120, 1.35, \"ABS 2021 Census\"\n], {\n fixed: true, highlight: false,\n fontSize: 10\n})\n\n\nfor (let i=0; iThe following boxplot reports the (median) weekly household income in 2021 across Sydney's 33 LGAs. Each diamond represents an LGA, and hovering over it will show you its name and income.

\n

{boxplot()}

\n

Weekly household income is a [[0]] variable, and since it is the only variable that makes up the boxplot this chart is univariate.

\n
\n

The five vertical lines of the boxplot split Sydney's LGAs into four quartiles of equal sizes. Between the minimum value and the first quartile (where the middle box begins, represented by Bayside) are the 25% of suburbs with the lowest household income. Between the first quartile and the second quartile (the middle line through the box) are the next 25% of suburbs and so on.

\n

These quartiles are denoted $Q_1$, $Q_2$ and $Q_3$. The minimum is $Q_0$ and the maximum is $Q_4$. The value $Q_2$ is also known as the median, and represents the middle observation in the data. In our data this is represented by the City of Sydney LGA, with an income of \\$ [[1]].

\n
\n

The range of the data is $Q_4-Q_0$, which is the difference in income between the poorest LGA (Fairfield) and the richest (Wollahra), which is $\\$$ [[2]].

\n

If one observation is much more extreme than the others, the range can appear really large even if the rest of the data is quite close together. We say that the \"range is not robust against outliers\". Because of this, we often use the interquartile range $$\\mathrm{IQR}=Q_3-Q_1,$$ which calculates the range for the \"middle 50%\" of the data. The $\\mathrm I\\mathrm Q\\mathrm R$ for this data is [[3]].

\n
\n

We can also calculate the mean, variance and standard deviation of the household incomes as before. The mean across all LGAs is $\\$2263$, which is [[4]] the median.

", "gaps": [{"type": "1_n_2", "useCustomName": true, "customName": "type", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["numeric", "categorical", "ordinal"], "matrix": ["1", 0, 0], "distractors": ["", "", ""]}, {"type": "numberentry", "useCustomName": true, "customName": "median", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "2212-200", "maxValue": "2212+200", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "range", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "(3192-1390)-400", "maxValue": "(3192-1390)+400", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "IQR", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "(2556-1959)-400", "maxValue": "(2556-1959)+400", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "1_n_2", "useCustomName": true, "customName": "compared", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["much higher than", "slightly higher than", "the same as", "slightly lower than", "much lower than"], "matrix": [0, "1", 0, 0, 0], "distractors": ["", "", "", "", ""]}], "sortAnswers": false, "inlineCorrectAnswer": true}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "showAllParts": false}, {"name": "Histograms", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": ["question-resources/skewness.png"], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "feedback": {"showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showpartfeedbackmessageswhen": "always", "allowrevealanswer": true, "showexpectedanswerswhen": "inreview", "showadvicewhen": "inreview"}, "contributors": [{"name": "Fern Gossow", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/38158/"}], "tags": [], "metadata": {"description": "", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": [], "variable_groups": [], "functions": {"histogram": {"parameters": [], "type": "html", "language": "javascript", "definition": "// Histogram of house price sales in Parramatta in 2025\n\nconst div = Numbas.extensions.jsxgraph.makeBoard('500px','250px',{\n boundingBox: [-270,200,2950,-30],\n axis: true,\n defaultAxes: {\n x: {highlight: false, ticks: {majorHeight: 5}},\n y: {highlight: false, ticks: {majorHeight: 5, minorHeight: 0}}\n },\n pan: {enabled: false}, zoom: {enabled: false}\n});\n\nconst board = div.board;\n\nconst heights = [\n 3, 1, 0, 3, 13, 18, 6, 11, 36, 66, 87, 157,\n 182, 103, 69, 49, 45, 20, 12, 7, 10, 6, 8, 7,\n 9, 7, 7, 5, 4, 5, 5, 0, 1, 3, 3, 2,\n 2, 2, 0, 1, 2, 1, 1, 1, 2, 0, 0, 1,\n 0, 1, 3, 0, 0, 2, 0, 1, 0, 0, 0, 0,\n 4\n];\n\nvar bars = [];\nfor (var i=0; i a + b, 0);\nlet cutoff = -1;\n\nconst label = board.create(\"text\", [2900, 175, \"\"], {\n fixed: true, highlight: false, anchorX: \"right\"\n});\n\nboard.on(\"move\", event => {\n const x = board.getUsrCoordsOfMouse(event)[0];\n const bin = Math.floor(x / 50);\n\n if (bin === cutoff || bin < 0 || bin >= bars.length) return;\n cutoff = bin;\n\n let count = 0;\n bars.forEach((bar, i) => {\n bar.setAttribute({ fillColor: i <= bin ? \"#F29E4C\" : \"#3F61C4\" });\n if (i <= bin) count += heights[i];\n });\n\n label.setText( `${count} of ${total} sales (${(100 * count / total).toFixed(1)}%)`);\n});\n\n\nreturn div;"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "prompt": "

Although boxplots provide a quick summary of the \"usual\" range of values in a dataset, they often fail to properly reflect the overall shape of the data. They also require the data to be numeric. When performing analysis on a single ordinal or numeric variable with many observations, it is very common to use a histogram.

\n

Below is a histogram of the price of every house sold in Paramatta in 2025. The prices are binned into ranges of $\\$50,000$. This turns the univariate data into bivariate data, where each price range is given a count of how many sales were in that range.

\n

{histogram()}

\n

House price is a [[0]] variable, but price range is [[1]], which is reported on the $x$-axis.

\n

On the $y$-axis is the count for each range, which is [[2]]. It is also typical to instead report the proportion, obtained by dividing the count by the total.

\n
\n

We can calculate all of the previous statistics on this data. The 'usual value' is determined by the mean and median, and the spread of the data by the variance, standard deviation, range and interquartile range.

\n

Histograms obtained by binning also have a mode, which is the most common observation. In this case the most common range for house prices is 600—650 thousand \\$AUD, with approximately [[3]] observations.

\n
\n

Hover over the chart to see the proportion of house prices in bins to the left of your cursor. The median value of the data occurs when the proportion crosses over the 50% threshold, at around [[4]] thousand \\$AUD. The median is also known as the 50th percentile, because 50% of house prices are smaller than this value.

\n

Similarly, the 90th percentile is the value bigger than exactly 90% of house prices, which is at approximately [[5]] thousand \\$AUD.

\n

The first quartile $Q_1$ is the 25th percentile, at approximately [[6]] thousand \\$AUD. Similarly, the third quartile $Q_3$ is the same as the 75th percentile.

\n
\n

Notice that this data has a large number of positive outliers, or house prices far above the usual range. The mean house price in this data set is $\\mu=715$ thousand \\$AUD, which is [[7]] the median. We say the data is right-skewed or positively-skewed, because the shape of the data has a longer tail to the right (positive side).

\n

{image('resources/question-resources/skewness.png',35)}

", "gaps": [{"type": "1_n_2", "useCustomName": true, "customName": "type1", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["numeric", "categorical", "ordinal"], "matrix": ["1", 0, 0], "distractors": ["", "", ""]}, {"type": "1_n_2", "useCustomName": true, "customName": "type2", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["numeric", "categorical", "ordinal"], "matrix": ["0", 0, "1"], "distractors": ["", "", ""]}, {"type": "1_n_2", "useCustomName": true, "customName": "type3", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["numeric", "categorical", "ordinal"], "matrix": ["1", 0, "0"], "distractors": ["", "", ""]}, {"type": "numberentry", "useCustomName": true, "customName": "number", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "182-10", "maxValue": "182+10", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "median", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "575-50", "maxValue": "575+50", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "90th", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "1025-50", "maxValue": "1025+50", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "25th", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "625-50", "maxValue": "625+50", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "1_n_2", "useCustomName": true, "customName": "compare", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["higher than", "the same as", "lower than"], "matrix": ["1", 0, 0], "distractors": ["", "", ""]}], "sortAnswers": false, "inlineCorrectAnswer": true}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "showAllParts": false}, {"name": "Scatterplots 1", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "feedback": {"showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showpartfeedbackmessageswhen": "always", "allowrevealanswer": true, "showexpectedanswerswhen": "inreview", "showadvicewhen": "inreview"}, "contributors": [{"name": "Fern Gossow", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/38158/"}], "tags": [], "metadata": {"description": "", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": [], "variable_groups": [], "functions": {"scatterplot": {"parameters": [], "type": "html", "language": "javascript", "definition": "// Scatter plot of GDP vs life expectancy for Asian countries\n// World Bank 2024 data: North Korea, Syria and Yemen had no GDP data\n\n\nconst div = Numbas.extensions.jsxgraph.makeBoard('500px', '250px', {\n boundingBox: [-10,90,109,59.6],\n axis: true,\n showNavigation: false,\n defaultAxes: {\n x: {highlight: false, ticks: {majorHeight: 5}},\n y: {highlight: false, ticks: {majorHeight: 5, minorHeight: 0}}\n },\n pan: {enabled: false}, zoom: {enabled: false}\n});\n\nconst board = div.board;\n\nconst xaxis = board.create(\"axis\", [\n [0,64], [100,64]\n], {\n highlight: false,\n ticks: {majorHeight: 5, minorTicks: 3,\n label: {anchorX: \"middle\", anchorY: \"top\", offset: [0,-5]}\n },\n})\n\n\nconst COUNTRIES = [\n \"Afghanistan\", \"Armenia\", \"Azerbaijan\", \"Bahrain\", \"Bangladesh\",\n \"Bhutan\", \"Brunei Darussalam\", \"Cambodia\", \"China\", \"Cyprus\",\n \"Georgia\", \"India\", \"Indonesia\", \"Iran\", \"Iraq\", \"Israel\", \"Japan\",\n \"Jordan\", \"Kazakhstan\", \"South Korea\", \"Kuwait\", \"Kyrgyz Republic\",\n \"Laos\", \"Lebanon\", \"Malaysia\", \"Maldives\", \"Mongolia\", \"Myanmar\",\n \"Nepal\", \"Oman\", \"Pakistan\", \"Philippines\", \"Qatar\", \"Russia\",\n \"Saudi Arabia\", \"Singapore\", \"Sri Lanka\", \"Tajikistan\", \"Thailand\",\n \"Timor-Leste\", \"T\u00fcrkiye\", \"Turkmenistan\", \"United Arab Emirates\",\n \"Uzbekistan\", \"Vietnam\", \"West Bank and Gaza\"\n];\n\nconst GDP = [\n 0.417, 8.556, 7.295, 29.717, 2.593,\n 4.228, 33.153, 2.628, 13.293, 38.674,\n 8.968, 2.592, 4.925, 5.190, 6.074, 54.217, 33.797,\n 5.074, 14.155, 36.239, 32.856, 2.515,\n 2.124, 4.473, 11.874, 13.379, 6.751, 1.359,\n 1.460, 20.285, 1.479, 3.985, 75.685, 14.962,\n 35.528, 94.897, 4.545, 1.362, 7.387,\n 1.332, 15.893, 5.904, 50.274,\n 3.337, 4.717, 3.028\n];\n\nconst LE = [\n 66.29, 78.32, 74.58, 81.42, 74.93,\n 73.26, 75.50, 70.82, 78.02, 81.82,\n 74.66, 72.24, 71.29, 77.85, 72.42, 83.20, 84.04,\n 77.98, 74.53, 83.63, 84.58, 72.40,\n 69.23, 77.95, 76.82, 81.28, 72.40, 67.10,\n 70.64, 80.25, 67.80, 69.95, 82.52, 73.44,\n 78.98, 83.35, 77.67, 71.93, 76.56,\n 67.90, 77.42, 70.20, 83.07,\n 72.53, 74.74, 69.21\n];\n\n\nvar points = [];\nfor (var i=0; i',\n size: 4,\n highlight: false,\n showInfobox: false,\n fillColor: \"#3F61C4\",\n strokeWidth: 0,\n withLabel: false\n }))\n}\n\nvar xlabel = board.create(\"text\", [\n 35, 60.75, \"GDP per capita (thousands of \\$USD)\"\n], {\n fontSize: 11,\n layer: 9,\n fixed: true, highlight: false\n})\n\nvar ylabel = board.create(\"text\", [\n -7.5, 70, \"Life expectancy (years)\"\n], {\n fontSize: 11,\n layer: 9,\n rotate: 90,\n fixed: true, highlight: false\n})\n\nreturn div;"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "prompt": "

The below chart graphs the life expectancy of every country in Asia (excl. North Korea, Yemen and Syria) against its GDP per capita based on 2024 data from the World Bank.

\n

{scatterplot()}

\n

GDP per capita is a [[0]] variable and life expectacy is [[1]]. This chart is bivariate, and we can calculate the mean, median, variance, percentiles and all other descriptive statistics so far for each variable separately.

\n

For example, if $x_C$ is the $x$-coordinate of the point corresponding to country $C$ (representing its GDP per capita), then the average of this measure across all countries is:

\n

[[2]] where $n$ is the total number of countries, and the variance is:

\n

[[3]]We define $\\mu_y$ and $\\sigma_y^2$ similarly for life expectancy, the variable on the $y$-axis.

\n
\n

We can also define statistics which describe the relationship between our two variables. The covariance between the two variables is given by$$\\mathrm{Covar}=\\frac{1}{n}\\sum_C(x_C-\\mu_X)(y_C-\\mu_y).$$A positive covariance means the $y$-values tend to increase along with the $x$-values, and a negative covariance means the $y$-values tend to decrease as the $x$-values increase.

\n

It also turns out that we have the inequality $-\\sigma_x\\sigma_y\\leq \\mathrm{Covar}\\leq \\sigma_x\\sigma_y$ and so we can normalise this statistic to obtain the correlation coefficient$$r=\\frac{\\mathrm{Covar}}{\\sigma_x\\sigma_y}$$which is always between $-1$ and $1$.

\n

In our example, $\\mathrm{Covar}=75.3$, $\\sigma_x=20.3$ and $\\sigma_y=5.1$, so $r=$ [[4]] (answer to two decimal places). This shows a [[5]] relationship between GDP per capita and life expectancy.

", "gaps": [{"type": "1_n_2", "useCustomName": true, "customName": "type1", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["numeric", "categorical", "ordinal"], "matrix": ["1", 0, 0], "distractors": ["", "", ""]}, {"type": "1_n_2", "useCustomName": true, "customName": "type2", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["numeric", "categorical", "ordinal"], "matrix": ["1", 0, 0], "distractors": ["", "", ""]}, {"type": "1_n_2", "useCustomName": true, "customName": "mean", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["$\\displaystyle\\vphantom{\\frac{1}{n}}\\mu_x=\\sum_C x_C$", "$\\displaystyle\\mu_x=\\frac{1}{n}\\sum_C x_C$", "$\\displaystyle\\mu_x=\\frac{1}{n}\\sum_C x_C^2$"], "matrix": [0, "1", 0], "distractors": ["", "", ""]}, {"type": "1_n_2", "useCustomName": true, "customName": "variance", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["$\\displaystyle\\sigma_x^2=\\frac{1}{n}\\sum_{C}(x_C^2-\\mu)$", "$\\displaystyle\\sigma_x^2=\\frac{1}{n}\\sum_{C}(x_C-\\mu)$", "$\\displaystyle\\sigma_x^2=\\frac{1}{n}\\sum_{C}(x_C-\\mu)^2$"], "matrix": [0, "1", 0], "distractors": ["", "", ""]}, {"type": "numberentry", "useCustomName": true, "customName": "r", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "75.3/(20.3*5.1)-0.01", "maxValue": "75.3/(20.3*5.1)+0.01", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "0.73", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "1_n_2", "useCustomName": true, "customName": "direction", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "dropdownlist", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["positive", "negative", "negligible"], "matrix": ["1", 0, 0], "distractors": ["", "", ""]}], "sortAnswers": false, "inlineCorrectAnswer": true}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "showAllParts": false}, {"name": "Scatterplots 2", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "feedback": {"showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showpartfeedbackmessageswhen": "always", "allowrevealanswer": true, "showexpectedanswerswhen": "inreview", "showadvicewhen": "inreview"}, "contributors": [{"name": "Fern Gossow", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/38158/"}], "tags": [], "metadata": {"description": "", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": [], "variable_groups": [], "functions": {"bestfit": {"parameters": [], "type": "html", "language": "javascript", "definition": "// Scatter plot of GDP vs life expectancy for Asian countries\n// World Bank 2024 data: North Korea, Syria and Yemen had no GDP data\n// Includes line of best fit\n\nconst div = Numbas.extensions.jsxgraph.makeBoard('500px', '250px', {\n boundingBox: [-10,90,109,59.6],\n axis: true,\n showNavigation: false,\n defaultAxes: {\n x: {highlight: false, ticks: {majorHeight: 5}},\n y: {highlight: false, ticks: {majorHeight: 5, minorHeight: 0}}\n },\n pan: {enabled: false}, zoom: {enabled: false}\n});\n\nconst board = div.board;\n\nconst xaxis = board.create(\"axis\", [\n [0,64], [100,64]\n], {\n highlight: false,\n ticks: {majorHeight: 5, minorTicks: 3,\n label: {anchorX: \"middle\", anchorY: \"top\", offset: [0,-5]}\n },\n})\n\n\nconst COUNTRIES = [\n \"Afghanistan\", \"Armenia\", \"Azerbaijan\", \"Bahrain\", \"Bangladesh\",\n \"Bhutan\", \"Brunei Darussalam\", \"Cambodia\", \"China\", \"Cyprus\",\n \"Georgia\", \"India\", \"Indonesia\", \"Iran\", \"Iraq\", \"Israel\", \"Japan\",\n \"Jordan\", \"Kazakhstan\", \"South Korea\", \"Kuwait\", \"Kyrgyz Republic\",\n \"Laos\", \"Lebanon\", \"Malaysia\", \"Maldives\", \"Mongolia\", \"Myanmar\",\n \"Nepal\", \"Oman\", \"Pakistan\", \"Philippines\", \"Qatar\", \"Russia\",\n \"Saudi Arabia\", \"Singapore\", \"Sri Lanka\", \"Tajikistan\", \"Thailand\",\n \"Timor-Leste\", \"T\u00fcrkiye\", \"Turkmenistan\", \"United Arab Emirates\",\n \"Uzbekistan\", \"Vietnam\", \"West Bank and Gaza\"\n];\n\nconst GDP = [\n 0.417, 8.556, 7.295, 29.717, 2.593,\n 4.228, 33.153, 2.628, 13.293, 38.674,\n 8.968, 2.592, 4.925, 5.190, 6.074, 54.217, 33.797,\n 5.074, 14.155, 36.239, 32.856, 2.515,\n 2.124, 4.473, 11.874, 13.379, 6.751, 1.359,\n 1.460, 20.285, 1.479, 3.985, 75.685, 14.962,\n 35.528, 94.897, 4.545, 1.362, 7.387,\n 1.332, 15.893, 5.904, 50.274,\n 3.337, 4.717, 3.028\n];\n\nconst LE = [\n 66.29, 78.32, 74.58, 81.42, 74.93,\n 73.26, 75.50, 70.82, 78.02, 81.82,\n 74.66, 72.24, 71.29, 77.85, 72.42, 83.20, 84.04,\n 77.98, 74.53, 83.63, 84.58, 72.40,\n 69.23, 77.95, 76.82, 81.28, 72.40, 67.10,\n 70.64, 80.25, 67.80, 69.95, 82.52, 73.44,\n 78.98, 83.35, 77.67, 71.93, 76.56,\n 67.90, 77.42, 70.20, 83.07,\n 72.53, 74.74, 69.21\n];\n\n\nvar points = [];\nfor (var i=0; i',\n size: 4,\n highlight: false,\n showInfobox: false,\n fillColor: \"#3F61C4\",\n strokeWidth: 0,\n withLabel: false\n }))\n}\n\n\nconst v1 = board.create(\"segment\", [\n [0,62], [0,88]\n], {\n visible: false\n})\n\nconst v2 = board.create(\"segment\", [\n [62,62], [62,88]\n], {\n visible: false\n})\n\nvar p = board.create(\"glider\", [\n 0, 80, v1\n], {\n showInfobox: false,\n highlight: false,\n fillColor: \"black\",\n strokeWidth: 0,\n size: 4\n})\nvar q = board.create(\"glider\", [\n 62, 70, v2\n], {\n showInfobox: false,\n highlight: false,\n fillColor: \"black\",\n strokeWidth: 0,\n size: 4\n})\n\n\n\nvar residuals = [];\n\n\nvar RSME = function() {\n sqsum = 0;\n for (let i=0; i 3.50 || RSME() < 3.42) {\n return \"#FF635D\";\n } else {\n return \"#1AC987\";\n }\n}\n\nvar fitline = board.create(\"line\", [\n p, q\n], {\n strokeColor: col,\n highlight: false,\n dash: 0,\n layer: 6,\n strokeWidth: 3,\n straightFirst: false\n});\n\n\nfor (let i = 0; i < points.length; i++) {\n const p = points[i];\n const vertical = board.create('line', [\n p,\n [() => p.X(), () => -p.Y()]\n ], {\n visible: false,\n fixed: true\n });\n\n const fittedPoint = board.create('intersection', [vertical, fitline, 0], {\n visible: false\n });\n\n residuals.push(board.create('segment', [p, fittedPoint], {\n strokeColor: '#999999',\n highlight: false,\n strokeWidth: 1,\n layer: 5\n }));\n}\n\n\nvar error_text = board.create(\"text\", [\n 70, 68.5, \"Current error:\"\n],{\n fixed: true, highlight: false,\n strokeColor: col\n});\n\nvar error_text_2 = board.create(\"text\", [\n 70, 68.5-2, \"Best possible:\"\n],{\n fixed: true, highlight: false,\n});\n\nvar years_text = board.create(\"text\", [\n 102.7, 68.5, \"years\"\n], {\n fixed: true, highlight: false,\n anchorX: \"right\",\n strokeColor: col\n});\n\nvar years_text = board.create(\"text\", [\n 102.7, 68.5-2, \"years\"\n], {\n fixed: true, highlight: false,\n anchorX: \"right\"\n});\n\nvar res_text = board.create(\"text\", [\n 95, 68.5, \n function() {return RSME().toFixed(2);}\n],{\n fixed: true, highlight: false,\n anchorX: \"right\",\n strokeColor: col\n});\n\nvar res_text_2 = board.create(\"text\", [\n 95, 68.5-2, \"3.46\"\n],{\n fixed: true, highlight: false,\n anchorX: \"right\"\n});\n\n\nvar background = board.create(\"polygon\", [\n [68.5,69.6], [103.5,69.6], [103.5,65.2], [68.5,65.2]\n], {\n vertices: {\n face: \"[]\",\n size: 1,\n strokeColor: \"black\",\n highlight: false, fixed: true,\n showInfobox: false\n },\n borders: {strokeColor: \"black\",\n highlight: false, fixed: true,\n strokeOpacity: 1,\n strokeWidth: 4,\n layer: 8\n },\n fillColor: \"white\",\n layer: 8,\n fillOpacity: 1,\n highlight: false\n});\n\nvar xlabel = board.create(\"text\", [\n 35, 60.75, \"GDP per capita (thousands of \\$USD)\"\n], {\n fontSize: 11,\n layer: 9,\n fixed: true, highlight: false\n})\n\nvar ylabel = board.create(\"text\", [\n -7.5, 70, \"Life expectancy (years)\"\n], {\n fontSize: 11,\n layer: 9,\n rotate: 90,\n fixed: true, highlight: false\n})\n\nreturn div;"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "prompt": "

The plot below is the same as before, but we have now added a supposed linear relationship between these variables, currently guessing that life expectancy decreases as GDP per capita increases. You can adjust this model by dragging the two black dots up and down. Fitting a linear model to a scatterplot like this is called linear regression.

\n

{bestfit()}

\n

Each grey vertical line represents the prediction error of the model: the difference between the actual life expectancy value $y_C$ for each country and the value $\\widehat{y}_C$ predicted by the model. The total error is the mean squared error$$\\mathrm{MSE}=\\frac{1}{n}\\sum_C(y_C-\\widehat{y}_C)^2.$$Squaring ensures that both over-prediction and under-prediction count positively towards the error.

\n
\n

The line of best fit is the linear model which makes $\\mathrm{MSE}$ as small as possible. Try to move the points around until the Current error is as close as possible to the best error. The line will turn green when you do this.

\n

It turns out that the line of best fit is always given by the equation$$y=r\\cdot\\frac{\\sigma_y}{\\sigma_x}\\cdot(x-\\mu_x)+\\mu_y$$which means the line has gradient:

\n

[[0]]and it passes through the point:

\n

[[1]]

\n
\n

For the data above the line of best fit is given by$$y=0.18x+72.7.$$

\n

For a country with a GDP per capita of 45 thousand \\$USD, this model predicts a life expectancy of [[2]] years.

\n

Australia has a life expectancy of around 83 years. Using this model, Australia's predicted GDP per capita is [[3]] thousand \\$USD.

\n

Looking again at the scatterplot and its line of best fit, does a linear model look appropriate here, or would some other type of function be better suited for modelling this data?

", "gaps": [{"type": "1_n_2", "useCustomName": true, "customName": "gradient", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["$\\displaystyle r\\cdot\\frac{\\sigma_y}{\\sigma_x}$", "$\\displaystyle \\frac{\\mu_y}{\\mu_x}$", "$\\displaystyle \\frac{\\mu_x}{\\mu_y}$"], "matrix": ["1", 0, 0], "distractors": ["", "", ""]}, {"type": "1_n_2", "useCustomName": true, "customName": "point", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showBlankOption": true, "showCellAnswerState": true, "interpretedAnswerForm": "list of list of boolean", "choices": ["$(\\sigma_x,\\sigma_y)$", "$(\\sigma_y,\\sigma_x)$", "$(\\mu_x,\\mu_y)$", "$(\\mu_y,\\mu_x)$"], "matrix": ["0", 0, "1", 0], "distractors": ["", "", "", ""]}, {"type": "numberentry", "useCustomName": true, "customName": "LE", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "0.18*45+72.7-1", "maxValue": "0.18*45+72.7+1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "80.8", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "GDP", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "minValue": "10.3/0.18-1", "maxValue": "10.3/0.18+1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "57.22", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false, "inlineCorrectAnswer": true}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "showAllParts": false}]}], "allowPrinting": true, "navigation": {"allowregen": false, "reverse": true, "browse": true, "allowsteps": false, "showfrontpage": true, "navigatemode": "sequence", "onleave": {"action": "none", "message": ""}, "preventleave": false, "typeendtoleave": false, "startpassword": "", "autoSubmit": true, "allowAttemptDownload": false, "downloadEncryptionKey": "", "showresultspage": "oncompletion"}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "feedback": {"enterreviewmodeimmediately": true, "showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showpartfeedbackmessageswhen": "never", "showexpectedanswerswhen": "never", "showadvicewhen": "never", "allowrevealanswer": false, "intro": "

Analysing patterns in data requires the use of both numeric and graphical summaries. Which tools you can use depends on the type of data you have.

\n

In this module, we go through a number of examples of statistical charts including bar charts, boxplots, histograms and scatterplots. For each chart, we calculate numerical summaries related to the data, including calculations of the mean, median, percentiles, interquartile range and correlation coefficient.

\n
\n

Complete the module by filling in the blanks on each page. You can submit answers immediately to see if they are correct, and you have unlimited attempts on all quesitons. If you close the tab, your progress will be saved.

\n

We recommend completing this module on a laptop, with a handheld calculator nearby to assist in any calculations.

\n

If you have feedback on this module, please email the Numeracy Skills team!

", "end_message": "", "results_options": {"printquestions": false, "printadvice": true}, "feedbackmessages": [], "reviewshowexpectedanswer": false, "showanswerstate": false, "reviewshowfeedback": true, "showactualmark": true, "showtotalmark": true, "reviewshowscore": true, "reviewshowadvice": false}, "diagnostic": {"knowledge_graph": {"topics": [], "learning_objectives": []}, "script": "diagnosys", "customScript": ""}, "contributors": [{"name": "Fern Gossow", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/38158/"}], "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [["question-resources/rba-chart.png", "74a80da77223907aee0e85ac8dad0ff232bb712df259c2292ee0dea71930260d.png"], ["question-resources/skewness.png", "569138bebf7d219fbdb40702556d29365254f4b9b3b16d5561bcf8ff7a95b4be.png"]]}