// Numbas version: finer_feedback_settings {"name": "Explore Mode - explore distribution of sample, select sample size and histogram bins (continuous distributions)", "extensions": ["stats", "jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Explore Mode - explore distribution of sample, select sample size and histogram bins (continuous distributions)", "tags": ["interactive", "Statistical estimation,"], "metadata": {"description": "
The student is presented with a scenario then asked to select a sample size to investigate and the number of bins for a histogram of the data. Theoretical distributions of normal, uniform and lognormal distributions can be overlayed on the histogram. Student is asked to identify the most likely distribution and the mean of this distribution (within a +/-10% margin of error).
", "licence": "None specified"}, "statement": "", "advice": "", "rulesets": {}, "extensions": ["jsxgraph", "stats"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"n": {"name": "n", "group": "Ungrouped variables", "definition": "100", "description": "Default sample size for random sample to be used in question - can be modified by question
", "templateType": "anything", "can_override": true}, "mean": {"name": "mean", "group": "Ungrouped variables", "definition": "if(distIndex=2,random(2..30),random(50..150 #10))", "description": "Mean of sample. If distindex selects Poisson value in range 2 to 10, otherwise 50 to 150 in steps of 10.
", "templateType": "anything", "can_override": true}, "sd": {"name": "sd", "group": "Ungrouped variables", "definition": "if(distIndex=2,mean,random(10..20))", "description": "Standard deviation for sample (not used if Poisson distribution is chosen).
", "templateType": "anything", "can_override": true}, "normDist": {"name": "normDist", "group": "Charts for histogram modeling", "definition": "jessiecode(700, 400, [binMid[0]-binWidth, 1.1*max(binFreq), binMid[binsNumber-1]+binWidth, max(-0.1,-0.1*maxFreq)],\"columnColours={columnColours};m={mean};sd={sd};small={sampleMin};large={sampleMax};binMid={binMid};binFreq={binFreq};binWidth={binWidth};max={maxFreq}; \"+ safe(\"\"\"\n \n \n functiongraph(function(x){return max*exp(-0.5*((x-m)/sd)^2);}, small, large) <normal distribution superimposed on sample histogram
", "templateType": "anything", "can_override": false}, "uniformDist": {"name": "uniformDist", "group": "Charts for histogram modeling", "definition": "jessiecode(700, 400, [binMid[0]-binWidth, 1.1*max(binFreq), binMid[binsNumber-1]+binWidth, max(-0.1,-0.1*maxFreq)], \"\"\"\n \n chart({binMid},{binFreq} ) <uniform distribution superimposed on sample histogram
", "templateType": "anything", "can_override": false}, "poissonDist": {"name": "poissonDist", "group": "Charts for histogram modeling", "definition": "jessiecode(700, 400, [binMid[0]-binWidth, 1.1*max(binFreq), binMid[binsNumber-1]+binWidth, max(-0.1,-0.1*maxFreq)], \"\"\"\n \n chart({binMid},{binFreq} ) <Poisson distribution superimposed on sample histogram. Values are calculated for integer closest to centre of each bin.
", "templateType": "anything", "can_override": false}, "dataSelected": {"name": "dataSelected", "group": "Ungrouped variables", "definition": "if(distIndex=0,repeat(uniformsample(int(mean-sd*0.5*sqrt(12)),int(mean+sd*0.5*sqrt(12))),n),\n if(distIndex=1,repeat(normalsample(mean,sd),n),repeat(lognormalsample(lnmu(mean,sd^2),lnsigma(mean,sd^2)),n)))", "description": "The sample used for the rest of the question. Sample size can be overridden by student input from first part. Depends on distIndex for type of distribution.
", "templateType": "anything", "can_override": false}, "distIndex": {"name": "distIndex", "group": "Ungrouped variables", "definition": "random(0,1,2)", "description": "Select the distribution to be displayed - 0 is Uniform distribution, 1 is Normal distribution, 2 is Poisson distribution
", "templateType": "anything", "can_override": false}, "visSelected": {"name": "visSelected", "group": "Histogram data", "definition": "jessiecode(700, 400, [binMid[0]-binWidth, 1.1*max(binFreq), binMid[binsNumber-1]+binWidth, -0.1*maxFreq],\"\"\"\n \n chart({binMid},{binFreq} ) <Histogram of sample using number of bins selected by student in Histogram bins part
", "templateType": "anything", "can_override": false}, "sampleMax": {"name": "sampleMax", "group": "Histogram data", "definition": "max(dataSelected)", "description": "maximum value of selected sample
", "templateType": "anything", "can_override": false}, "sampleMin": {"name": "sampleMin", "group": "Histogram data", "definition": "min(dataSelected)", "description": "minimum value of selected sample
", "templateType": "anything", "can_override": false}, "binMax": {"name": "binMax", "group": "Histogram data", "definition": "map(sampleMin+(sampleMax-sampleMin)/binsNumber*x,x,(1..binsNumber))", "description": "Maximum value of each bin in data range calculated after variable replacement from bin Number part
", "templateType": "anything", "can_override": false}, "binFreqRest": {"name": "binFreqRest", "group": "Histogram data", "definition": "map(sum(map(if(dataselected[x]<=binMax[y+1] and dataselected[x]>binMax[y],1,0)/n,x,(0..n-1))),y,(0..binsNumber-2))", "description": "Relative frequency of data in bins 1..binMax-1 for histogram.
", "templateType": "anything", "can_override": false}, "binFreqFirst": {"name": "binFreqFirst", "group": "Histogram data", "definition": "[sum(map(if(dataselected[x]<=binMax[0],1,0)/n,x,(0..n-1)))]", "description": "Relative frequency of bin 0
", "templateType": "anything", "can_override": false}, "binFreq": {"name": "binFreq", "group": "Histogram data", "definition": "flatten([binfreqfirst,binfreqrest])", "description": "Relative requencies for each bin in histogram
", "templateType": "anything", "can_override": false}, "binMid": {"name": "binMid", "group": "Histogram data", "definition": "map(sampleMin+(sampleMax-sampleMin)/binsNumber*(x-0.5),x,(1..binsNumber))", "description": "Midpoints of each bin
", "templateType": "anything", "can_override": false}, "binWidth": {"name": "binWidth", "group": "Histogram data", "definition": "(sampleMax-sampleMin)/binsNumber", "description": "Width of each bin
", "templateType": "anything", "can_override": false}, "binsNumber": {"name": "binsNumber", "group": "Histogram data", "definition": "10", "description": "Number of bins to be used in histogram. Overridden by student selection in Histogram Bins part
", "templateType": "anything", "can_override": true}, "maxFreq": {"name": "maxFreq", "group": "Histogram data", "definition": "max(binfreq)", "description": "Maximum relative frequency of histogram. Used to scale JSXgraph elements
", "templateType": "anything", "can_override": true}, "poissonDistPoints": {"name": "poissonDistPoints", "group": "Charts for histogram modeling", "definition": "map(poissonScaling*customPoissonPDF(int(x)),x,binMid)//map(poissonScaling*exp(-mean)*mean^int(x)/fact(int(x)),x,binMid)", "description": "Points to display for Poisson distribution. If Poisson is selected for uniform or normal distribution values are set to 0 if x>110 due to calculation limitations.
", "templateType": "anything", "can_override": false}, "poissonScaling": {"name": "poissonScaling", "group": "Charts for histogram modeling", "definition": "maxFreq*fact(mean)/(exp(-mean)*mean^(mean))", "description": "Scaling factor applied to Poisson distribution so that it is comparable to histogram values.
", "templateType": "anything", "can_override": false}, "selectedDist": {"name": "selectedDist", "group": "Charts for mean estimation", "definition": "1", "description": "variable is replaced by student's selection of distribution type in Select Distribution part. used to determine which board will be displayed in Estimate Mean part.
", "templateType": "anything", "can_override": false}, "displayedDist": {"name": "displayedDist", "group": "Charts for mean estimation", "definition": "if(selectedDist=[[true],[false],[false]],uniformdistdisplay,\n if(selectedDist=[[false],[true],[false]],normdistdisplay,lognormdistdisplay))", "description": "The distribution to be displaued in the Estimate Mean section of question. Depends on student response to Selected Distribution question.
", "templateType": "anything", "can_override": false}, "uniformDistDisplay": {"name": "uniformDistDisplay", "group": "Charts for mean estimation", "definition": "jessiecode(700, 400, [binMid[0]-binWidth, 1.1*max(binFreq), binMid[binsNumber-1]+binWidth, max(-0.1,-0.1*maxFreq)], \"\"\"\n \n chart({binMid},{binFreq} ) <copy of uniform distribution for Estimate Mean part.
", "templateType": "anything", "can_override": false}, "poissonDistDisplay": {"name": "poissonDistDisplay", "group": "Charts for mean estimation", "definition": "jessiecode(700, 400, [binMid[0]-binWidth, 1.1*max(binFreq), binMid[binsNumber-1]+binWidth, max(-0.1,-0.1*maxFreq)], \"\"\"\n \n chart({binMid},{binFreq} ) <copy of Poisson distribution for Estimate Mean part.
", "templateType": "anything", "can_override": false}, "normDistDisplay": {"name": "normDistDisplay", "group": "Charts for mean estimation", "definition": "jessiecode(700, 400, [binMid[0]-binWidth, 1.1*max(binFreq), binMid[binsNumber-1]+binWidth, max(-0.1,-0.1*maxFreq)],\"columnColours={columnColours};m={mean};sd={sd};small={sampleMin};large={sampleMax};binMid={binMid};binFreq={binFreq};binWidth={binWidth};max={maxFreq}; \"+ safe(\"\"\"\n \n \n functiongraph(function(x){return max*exp(-0.5*((x-m)/sd)^2);}, small, large) <copy of normal distribution for Estimate Mean part.
", "templateType": "anything", "can_override": false}, "columnColours": {"name": "columnColours", "group": "Histogram data", "definition": "repeat(\"#E6A5AC\",binsNumber)", "description": "", "templateType": "anything", "can_override": false}, "question_scenario": {"name": "question_scenario", "group": "Ungrouped variables", "definition": "[[\"the time taken for an elevator to arrive once the button is pressed\", \"the distance that people stand back from the edge for a railway platoform\", \"the scores given to contestants in auditions for a talent show\"],[\"the length of the shell of a species of mussel\", \"the concentration of arsenic in a species of mussel\", \"the job satisfaction of a group of workers\"],[\"the level of vitamin D in blood serum\", \"the rugby league grand final winning margin\", \"the concentration of uranium in a species of mussel\", \"the concentration of lead in crocodile meat\" ]]", "description": "Scenarios used in description given to student. First list element are uniform distribution, second are uniform distribution, third Poisson distribution.
", "templateType": "anything", "can_override": false}, "selected_scenario": {"name": "selected_scenario", "group": "Ungrouped variables", "definition": "question_scenario[distIndex][random(0..length(question_scenario[distIndex])-1)]", "description": "Scenario used in the question.
", "templateType": "anything", "can_override": false}, "logNormDistDisplay": {"name": "logNormDistDisplay", "group": "Charts for mean estimation", "definition": "jessiecode(700, 400, [binMid[0]-binWidth, 1.1*max(binFreq), binMid[binsNumber-1]+binWidth, max(-0.1,-0.1*maxFreq)],\"columnColours={columnColours};m={mean};sd={sd};small={sampleMin};large={sampleMax};binMid={binMid};binFreq={binFreq};binWidth={binWidth};max={maxFreq}; \"+ safe(\"\"\"\n \n lnmu = function(m_, v_) {\n return ln(m_^2/(sqrt(v_+m_^2)));\n };\n \n lnsigma = function(m_, v_) {\n return sqrt(ln(v_/(m_^2)+1));\n };\n \n lnmax = function(mu_,sigma_) {\n return (1/(exp(mu_-sigma_^2)*sigma_*sqrt(2*PI)))*exp((-sigma_^2)/2);\n };\n \n mu = lnmu(m,sd^2);\n sigma = lnsigma(m,sd^2);\n lnmaxe = lnmax(mu,sigma);\n \n \n functiongraph(function(x){return (max/lnmaxe)*(1/(x*sigma*sqrt(2*PI)))*exp((-(ln(x)-mu)^2)/(2*sigma^2));}, small, large) <You have been asked to investigate {selected_scenario}, specifically to identify the statistical distribution which this follows and to estimate the mean value of the variable. To do this you will need to collect a sample of data and have this plotted as a histogram, then compare the histogram with known statistical distributions.
\nHow many observations will you need to take to estimate these things?
", "minValue": "50", "maxValue": "1000", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": 0, "precisionPartialCredit": 0, "precisionMessage": "Answer needs to be an integer.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Histogram Bins", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "numberInRange (Is the student's number in the allowed range?):\n if(studentNumber>=minvalue and studentNumber<=maxvalue and isInteger,\n correct(\"That number of bins should allow you to see the structure of the distribution\")\n ,\n if(studentNumberYou have decided to collect a sample consisting of \\(\\var{n}\\) observations. How many bins do you want to use for your histogram?
", "minValue": "5", "maxValue": "40", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": 0, "precisionPartialCredit": 0, "precisionMessage": "Answer needs to be an integer.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "information", "useCustomName": true, "customName": "Histogram", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [{"label": "Superimpose a lognormal distribution over the histogram", "rawLabel": "Superimpose a lognormal distribution over the histogram", "otherPart": 3, "variableReplacements": [], "availabilityCondition": "", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}, {"label": "Superimpose a uniform distribution over the histogram", "rawLabel": "Superimpose a uniform distribution over the histogram", "otherPart": 4, "variableReplacements": [], "availabilityCondition": "", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}, {"label": "Superimpose a normal distribution over the histogram", "rawLabel": "Superimpose a normal distribution over the histogram", "otherPart": 5, "variableReplacements": [], "availabilityCondition": "", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}], "suggestGoingBack": true, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "\nHere is a histogram of your \\(\\var{n}\\) observations of {selected_scenario} grouped in to \\(\\var{binsnumber}\\) intervals. If you would like to change the number of bins in the histogram choose the \"Go back to the previous part\" option below.
\n{visSelected}
"}, {"type": "information", "useCustomName": true, "customName": "Lognormal", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [{"label": "Select the distribution which fits this sample best", "rawLabel": "Select the distribution which fits this sample best", "otherPart": 6, "variableReplacements": [], "availabilityCondition": "", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}], "suggestGoingBack": true, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "{lognormDist}
"}, {"type": "information", "useCustomName": true, "customName": "Uniform", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [{"label": "Select the distribution which fits this sample best", "rawLabel": "Select the distribution which fits this sample best", "otherPart": 6, "variableReplacements": [], "availabilityCondition": "", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}], "suggestGoingBack": true, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "{uniformDist}
"}, {"type": "information", "useCustomName": true, "customName": "Normal", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [{"label": "Select the distribution which fits this sample best", "rawLabel": "Select the distribution which fits this sample best", "otherPart": 6, "variableReplacements": [], "availabilityCondition": "", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}], "suggestGoingBack": true, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "{normDist}
"}, {"type": "1_n_2", "useCustomName": true, "customName": "Select distribution", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [{"label": "Estimate the mean of the population", "rawLabel": "Estimate the mean of the population", "otherPart": 7, "variableReplacements": [{"variable": "selectedDist", "definition": "interpreted_answer"}], "availabilityCondition": "answered", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}], "suggestGoingBack": true, "adaptiveMarkingPenalty": 0, "exploreObjective": "Select distribution", "prompt": "Which distribution best fits the histogram you have generated?
", "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["Uniform distribution", "Normal distribution", "Lognormal distribution"], "matrix": ["if(distIndex=0,1,0)", "if(distIndex=1,1,0)", "if(distIndex=2,1,0)"], "distractors": ["", "", ""]}, {"type": "gapfill", "useCustomName": true, "customName": "Estimate Mean", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": "Estimate mean", "prompt": "You have selected the following distribution as the most likely model. Based on this estimate the mean of the population.
\n{displayedDist}
\nMean is approximately [[0]]
", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "Mean", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": "Estimate mean", "minValue": "0.9*{mean}", "maxValue": "1.1*{mean}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "information", "useCustomName": true, "customName": "Sample size hint", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": true, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "A sample needs to be a whole number (we can't collect a fraction of an observation) and needs to gether enough data to allow us to answer the question but not so much that it becomes cost prohibitive to collect it. Try a value between 50 and 1000.
"}, {"type": "information", "useCustomName": true, "customName": "Histogram bins hint", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": true, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "The number of bins (intervals) in a histogram needs to be an integer, we can't have a fraction of a bin. It needs to be large enough to show the structure of the sample, but small enough that it doesn't become a list of values. Try a number between 5 and 40.
"}], "partsMode": "explore", "maxMarks": "4", "objectives": [{"name": "Sample size", "limit": 1}, {"name": "Histogram bins", "limit": 1}, {"name": "Select distribution", "limit": "1"}, {"name": "Estimate mean", "limit": "1"}], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "contributors": [{"name": "Don Shearman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/680/"}, {"name": "Jim Pettigrew", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2037/"}, {"name": "Merryn Horrocks", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4052/"}, {"name": "Brent Le Cornu", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/18260/"}]}]}], "contributors": [{"name": "Don Shearman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/680/"}, {"name": "Jim Pettigrew", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2037/"}, {"name": "Merryn Horrocks", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4052/"}, {"name": "Brent Le Cornu", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/18260/"}]}