// Numbas version: exam_results_page_options {"name": "Explore Mode - explore distribution of sample, select sample size and histogram bins (discrete 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 (discrete 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),if(distIndex=1,binomialProb*binomtrials,uniformMin+(uniformMax-uniformMin)/2))", "description": "

Mean of sample. If distindex selects Poisson value in range 2 to 30, if distIndex selectes binomial value is binomialProb*binomialTrials, otherwise for uniform it is uniformmin+(uniformmax-uniformmin)/2.

", "templateType": "anything", "can_override": true}, "sd": {"name": "sd", "group": "Ungrouped variables", "definition": "if(distIndex=2,mean,if(distIndex=1,sqrt(binomtrials*(1-binomialProb)*binomialProb),sqrt((uniformMax-uniformMin)^2/12)) )", "description": "

Standard deviation for sample (not used if Poisson distribution is chosen). Value is based on binomialTrials and binomialProb for binomial sample, uniformmax and uniformmin for uniform distribution

", "templateType": "anything", "can_override": true}, "binomDist": {"name": "binomDist", "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)], \"sampleMin={sampleMin};binMax={binMax};binsNumber={binsNumber};binMid={binMid};binFreq={binFreq};binWidth={binWidth};columnColours={columnColours};binomPoints={binomPoints};sampleMax={sampleMax};xanchor={(binMid[0]+binMid[binsNumber-1])/2};yanchor={1.1*max(binFreq)};sampleSize={n};scenario={scenario};\"+safe(\"\"\"\n \n chart(binMid,binFreq ) <>;\n chart(binMid,binomPoints ) <>;\n text(xanchor,yanchor,\"Bar chart of \"+sampleSize+\" observations of \"+scenario+\" with Binomial distribution\") <>;\n \n if (binsNumber0) {\n lep = binMax[i-1]+0.5;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n } else {\n lep = sampleMin;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n }\n } \n } else {\n for (i=0; i>;\n }\n }\n \n \nyaxis = axis( [0,0],[0,1] ) <<\n withLabel: false, visible: false\n>>;\n \nxaxis = axis( [0,0],[1,0] ) <<\n withLabel: false\n>>; \n \nxaxis.removeAllTicks();\n \n \n \n\n \n \"\"\"),\n[\"axis\": false,\n \"showNavigation\": false,\n \"grid\": false,\n \"showCopyright\": false,\n \"keepaspectratio\": false \n ])", "description": "

binomiall distribution superimposed on sample bar chart. 

", "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)], \"sampleMin={sampleMin};binMax={binMax};binsNumber={binsNumber};binMid={binMid};binFreq={binFreq};binWidth={binWidth};columnColours={columnColours};sampleMax={sampleMax};meanbinFreq={mean(binFreq)};xanchor={(binMid[0]+binMid[binsNumber-1])/2};yanchor={1.1*max(binFreq)};sampleSize={n};scenario={scenario};\"+safe(\"\"\"\n \n chart(binMid,binFreq ) <>;\n segment([sampleMin,meanbinFreq],[sampleMax,meanbinFreq]);\n segment([sampleMin,0],[sampleMin,meanbinFreq]);\n segment([sampleMax,0],[sampleMax,meanbinFreq]);\n text(xanchor,yanchor,\"Bar chart of \"+sampleSize+\" observations of \"+scenario+\" with Uniform distribution\") <>;\n \n if (binsNumber0) {\n lep = binMax[i-1]+0.5;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n } else {\n lep = sampleMin;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n }\n } \n } else {\n for (i=0; i>;\n }\n }\n \n \nyaxis = axis( [0,0],[0,1] ) <<\n withLabel: false, visible: false\n>>;\n \nxaxis = axis( [0,0],[1,0] ) <<\n withLabel: false\n>>; \n \nxaxis.removeAllTicks();\n \n \n \n\n \n \"\"\"),\n[\"axis\": false,\n \"showNavigation\": false,\n \"grid\": false,\n \"showCopyright\": false,\n \"keepaspectratio\": false \n ])", "description": "

uniform distribution superimposed on sample bar chart

", "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)], \"sampleMin={sampleMin};binMax={binMax};binsNumber={binsNumber};binMid={binMid};binFreq={binFreq};binWidth={binWidth};columnColours={columnColours};poissonDistPoints={poissonDistPoints};sampleMax={sampleMax};xanchor={(binMid[0]+binMid[binsNumber-1])/2};yanchor={1.1*max(binFreq)};sampleSize={n};scenario={scenario};\"+safe(\"\"\"\n \n chart(binMid,binFreq ) <>;\n chart(binMid,poissonDistPoints ) <>;\n text(xanchor,yanchor,\"Bar chart of \"+sampleSize+\" observations of \"+scenario+\" with Poisson distribution\") <>;\n \n if (binsNumber0) {\n lep = binMax[i-1]+0.5;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n } else {\n lep = sampleMin;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n }\n } \n } else {\n for (i=0; i>;\n }\n }\n \n \nyaxis = axis( [0,0],[0,1] ) <<\n withLabel: false, visible: false\n>>;\n \nxaxis = axis( [0,0],[1,0] ) <<\n withLabel: false\n>>; \n \nxaxis.removeAllTicks();\n \n \n \n\n \n \"\"\"),\n[\"axis\": false,\n \"showNavigation\": false,\n \"grid\": false,\n \"showCopyright\": false,\n \"keepaspectratio\": false \n ])", "description": "

Poisson distribution superimposed on sample bar chart. 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(random(uniformMin..uniformMax),n),\n if(distIndex=1,repeat(sum(repeat((weighted_random([[1,binomialprob],[0,1-binomialprob]])),binomTrials)),n),repeat(poissonsample(mean),n)))", "description": "

The sample used for the rest of the qustion. 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 Binomial 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, max(-0.1,-0.1*maxFreq)], \"sampleMin={sampleMin};binMax={binMax};binsNumber={binsNumber};binMid={binMid};binFreq={binFreq};binWidth={binWidth};columnColours={columnColours};sampleMax={sampleMax};xanchor={(binMid[0]+binMid[binsNumber-1])/2};yanchor={1.1*max(binFreq)};sampleSize={n};scenario={scenario};\"+safe(\"\"\"\n \n chart(binMid,binFreq ) <>;\n text(xanchor,yanchor,\"Bar chart of \"+sampleSize+\" observations of \"+scenario) <>;\n \n if (binsNumber0) {\n lep = binMax[i-1]+0.5;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n } else {\n lep = sampleMin;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n }\n } \n } else {\n for (i=0; i>;\n }\n }\n \n \nyaxis = axis( [0,0],[0,1] ) <<\n withLabel: false, visible: false\n>>;\n \nxaxis = axis( [0,0],[1,0] ) <<\n withLabel: false\n>>; \n \nxaxis.removeAllTicks();\nyaxis.removeAllTicks();\n \n \n \n\n \n \"\"\"),\n[\"axis\": false,\n \"showNavigation\": false,\n \"grid\": false,\n \"showCopyright\": false,\n \"keepaspectratio\": false \n ])", "description": "

Bar Chart 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-0.5+(sampleMax-sampleMin+1)/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-0.5+(sampleMax-sampleMin+1)/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+1)/binsNumber", "description": "

Width of each bin

", "templateType": "anything", "can_override": false}, "binsNumber": {"name": "binsNumber", "group": "Histogram data", "definition": "sampleMax-sampleMin+1//10", "description": "

Number of bins to be used in bar chart. Overridden by student selection in Bar Chart Bins part

", "templateType": "anything", "can_override": true}, "maxFreq": {"name": "maxFreq", "group": "Histogram data", "definition": "max(binfreq)", "description": "

Maximum relative frequency of bar chart. Used to scale JSXgraph elements

", "templateType": "anything", "can_override": false}, "poissonDistPoints": {"name": "poissonDistPoints", "group": "Charts for histogram modeling", "definition": "map(poissonScaling*poissonpdf(int(x),int(mean)),x,binMid)//map(poissonScaling*exp(-mean)*mean^int(x)/fact(int(x)),x,binMid)", "description": "

Points to display for Poisson distribution. 

", "templateType": "anything", "can_override": false}, "poissonScaling": {"name": "poissonScaling", "group": "Charts for histogram modeling", "definition": "maxFreq/poissonpdf(int(mean),int(mean))", "description": "

Scaling factor applied to Poisson distribution so that it is comparable to bar chart 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]],binomdistdisplay,poissondistdisplay))", "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)], \"sampleMin={sampleMin};binMax={binMax};binsNumber={binsNumber};binMid={binMid};binFreq={binFreq};binWidth={binWidth};columnColours={columnColours};sampleMax={sampleMax};meanbinFreq={mean(binFreq)};xanchor={(binMid[0]+binMid[binsNumber-1])/2};yanchor={1.1*max(binFreq)};sampleSize={n};scenario={scenario};\"+safe(\"\"\"\n \n chart(binMid,binFreq ) <>;\n segment([sampleMin,meanbinFreq],[sampleMax,meanbinFreq]);\n segment([sampleMin,0],[sampleMin,meanbinFreq]);\n segment([sampleMax,0],[sampleMax,meanbinFreq]);\n text(xanchor,yanchor,\"Bar chart of \"+sampleSize+\" observations of \"+scenario+\" with Uniform distribution\") <>;\n \n if (binsNumber0) {\n lep = binMax[i-1]+0.5;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n } else {\n lep = sampleMin;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n }\n } \n } else {\n for (i=0; i>;\n }\n }\n \n \nyaxis = axis( [0,0],[0,1] ) <<\n withLabel: false, visible: false\n>>;\n \nxaxis = axis( [0,0],[1,0] ) <<\n withLabel: false\n>>; \n \nxaxis.removeAllTicks();\n \n \n \n\n \n \"\"\"),\n[\"axis\": false,\n \"showNavigation\": false,\n \"grid\": false,\n \"showCopyright\": false,\n \"keepaspectratio\": false \n ])", "description": "

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)], \"sampleMin={sampleMin};binMax={binMax};binsNumber={binsNumber};binMid={binMid};binFreq={binFreq};binWidth={binWidth};columnColours={columnColours};poissonDistPoints={poissonDistPoints};sampleMax={sampleMax};xanchor={(binMid[0]+binMid[binsNumber-1])/2};yanchor={1.1*max(binFreq)};sampleSize={n};scenario={scenario};\"+safe(\"\"\"\n \n chart(binMid,binFreq ) <>;\n chart(binMid,poissonDistPoints ) <>;\n text(xanchor,yanchor,\"Bar chart of \"+sampleSize+\" observations of \"+scenario+\" with Poisson distribution\") <>;\n \n if (binsNumber0) {\n lep = binMax[i-1]+0.5;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n } else {\n lep = sampleMin;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n }\n } \n } else {\n for (i=0; i>;\n }\n }\n \n \nyaxis = axis( [0,0],[0,1] ) <<\n withLabel: false, visible: false\n>>;\n \nxaxis = axis( [0,0],[1,0] ) <<\n withLabel: false\n>>; \n \nxaxis.removeAllTicks();\n \n \n \n\n \n \"\"\"),\n[\"axis\": false,\n \"showNavigation\": false,\n \"grid\": false,\n \"showCopyright\": false,\n \"keepaspectratio\": false \n ])", "description": "

copy of Poisson distribution for Estimate Mean part.

", "templateType": "anything", "can_override": false}, "binomDistDisplay": {"name": "binomDistDisplay", "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)], \"sampleMin={sampleMin};binMax={binMax};binsNumber={binsNumber};binMid={binMid};binFreq={binFreq};binWidth={binWidth};columnColours={columnColours};binomPoints={binomPoints};sampleMax={sampleMax};xanchor={(binMid[0]+binMid[binsNumber-1])/2};yanchor={1.1*max(binFreq)};sampleSize={n};scenario={scenario};\"+safe(\"\"\"\n \n chart(binMid,binFreq ) <>;\n chart(binMid,binomPoints ) <>;\n text(xanchor,yanchor,\"Bar chart of \"+sampleSize+\" observations of \"+scenario+\" with Binomial distribution\") <>;\n \n if (binsNumber0) {\n lep = binMax[i-1]+0.5;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n } else {\n lep = sampleMin;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n }\n } \n } else {\n for (i=0; i>;\n }\n }\n \n \nyaxis = axis( [0,0],[0,1] ) <<\n withLabel: false, visible: false\n>>;\n \nxaxis = axis( [0,0],[1,0] ) <<\n withLabel: false\n>>; \n \nxaxis.removeAllTicks();\n \n \n \n\n \n \"\"\"),\n[\"axis\": false,\n \"showNavigation\": false,\n \"grid\": false,\n \"showCopyright\": false,\n \"keepaspectratio\": false \n ])", "description": "

copy of binomial 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 of a railway platform\", \"the scores given to contestants in auditions for a talent show\"],[\"the total score for a skill based game\", \"the number of spam emails received in an inbox containing {binomTrials} messages\", \"the number of people who support a sports team from a sample of {binomTrials}\"],[\"the number of customers injured by shopping trolleys at a shopping centre each week\", \"the number of customers at a checkout per hour\", \"the number of a particular organism per millilitre of sea water\", \"the number of errors per page of a book draft\" ]]", "description": "

Scenarios used in description given to student. First list element are uniform distribution, second are binomial distribution, third Poisson distribution.

", "templateType": "anything", "can_override": true}, "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}, "binomialProb": {"name": "binomialProb", "group": "Ungrouped variables", "definition": "random(0.2..0.8 #0.05)", "description": "

p value used for binomial sample

", "templateType": "anything", "can_override": false}, "binomTrials": {"name": "binomTrials", "group": "Ungrouped variables", "definition": "random(3..20)", "description": "

n value for binomial sample

", "templateType": "anything", "can_override": false}, "uniformmax": {"name": "uniformmax", "group": "Ungrouped variables", "definition": "random(15..40)", "description": "

Maximum value for uniform distribution sample

", "templateType": "anything", "can_override": false}, "uniformmin": {"name": "uniformmin", "group": "Ungrouped variables", "definition": "random(0..uniformMax-5)", "description": "

Minimum value for uniform sample

", "templateType": "anything", "can_override": false}, "binomPoints": {"name": "binomPoints", "group": "Charts for histogram modeling", "definition": "map(if(binomialpdf(x,int(mean*2),0.5)=NaN,0,binomScaling*binomialpdf(x,int(mean*2),0.5)),x,binMid)", "description": "

Points to display for binomial distribution. Assumes that p=0.5, n= mean#2. Calculated values which result in NaN are replaced by 0

", "templateType": "anything", "can_override": false}, "binomScaling": {"name": "binomScaling", "group": "Charts for histogram modeling", "definition": "maxFreq/binomialpdf(int(mean),int(mean*2),0.5)", "description": "

Scaling factor used for binomial distribution graph

", "templateType": "anything", "can_override": false}, "binomialDistTest": {"name": "binomialDistTest", "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)], \"sampleMin={sampleMin};binMax={binMax};binsNumber={binsNumber};binMid={binMid};binFreq={binFreq};binWidth={binWidth};columnColours={columnColours};binomPoints={binomPoints};sampleMax={sampleMax};\"+safe(\"\"\"\n \n chart(binMid,binFreq ) <>;\n chart(binMid,binomPoints ) <>;\n \n if (binsNumber0) {\n lep = binMax[i-1]+0.5;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n } else {\n lep = sampleMin;\n uep = binMax[i]-0.5;\n text(binMid[i],0,lep+\"-\"+uep) <>;\n }\n } \n } else {\n for (i=0; i>;\n }\n }\n \n \nyaxis = axis( [0,0],[0,1] ) <<\n withLabel: false\n>>;\n \nxaxis = axis( [0,0],[1,0] ) <<\n withLabel: false\n>>; \n \nxaxis.removeAllTicks();\n \n \n \n\n \n \"\"\"),\n[\"axis\": false,\n \"showNavigation\": false,\n \"grid\": false,\n \"showCopyright\": false,\n \"keepaspectratio\": false \n ])", "description": "", "templateType": "anything", "can_override": false}, "scenario": {"name": "scenario", "group": "Ungrouped variables", "definition": "'\"'+selected_scenario+'\"'", "description": "

String passed to title of bar charts

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["n", "mean", "sd", "dataSelected", "distIndex", "question_scenario", "selected_scenario", "binomialProb", "binomTrials", "uniformmax", "uniformmin", "scenario"], "variable_groups": [{"name": "Histogram data", "variables": ["sampleMax", "sampleMin", "binMax", "binMid", "binWidth", "binFreqRest", "binFreqFirst", "binFreq", "visSelected", "binsNumber", "maxFreq", "columnColours"]}, {"name": "Charts for histogram modeling", "variables": ["uniformDist", "poissonDist", "poissonDistPoints", "poissonScaling", "binomDist", "binomPoints", "binomScaling", "binomialDistTest"]}, {"name": "Charts for mean estimation", "variables": ["poissonDistDisplay", "binomDistDisplay", "uniformDistDisplay", "displayedDist", "selectedDist"]}], "functions": {"Histogram": {"parameters": [["binMid", "list"], ["binWidth", "number"], ["binFreq", "list"], ["maxFreq", "number"]], "type": "anything", "language": "jme", "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} ) <>;\n \n \n \"\"\",\n[\"axis\": true,\n \"showNavigation\": false,\n \"grid\": false,\n \"showCopyright\": false,\n \"keepaspectratio\": false \n ])\n\n "}, "customPoissonPDF": {"parameters": [["x", "number"]], "type": "anything", "language": "jme", "definition": "if(exp(-mean)*mean^int(x)/fact(int(x))=NaN or exp(-mean)*mean^int(x)/fact(int(x))=infinity,0,exp(-mean)*mean^int(x)/fact(int(x)))"}, "lnmu": {"parameters": [["m_", "number"], ["v_", "number"]], "type": "anything", "language": "jme", "definition": "ln(m_^2/(sqrt(v_+m_^2)))"}, "lnsigma": {"parameters": [["m_", "number"], ["v_", "number"]], "type": "anything", "language": "jme", "definition": "sqrt(ln(v_/(m_^2)+1))"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": true, "customName": "Sample Size", "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(\"This sample size is a reasonable number of cases to examine\")\n ,\n if(studentNumbermaxvalue and isInteger,\n incorrect(\"A sample this large will be very expensive to construct and probably won't give value for money. Try a value less than 1000.\"),\n incorrect(\"The sample size needs to be an integer.\")));\n end()\n )\n\nmark:\n apply(validNumber);\n apply(numberInRange);\n assert(numberInRange,end());\n if(isFraction,\n apply(cancelled)\n ,\n apply(correctPrecision)\n )\n\ninterpreted_answer (The student's answer, to be reused by other parts):\n apply(validNumber);\n studentNumber", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": false, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [{"label": "Select number of bins for the bar chart", "rawLabel": "Select number of bins for the bar chart", "otherPart": 1, "variableReplacements": [{"variable": "n", "definition": "int(interpreted_answer)"}], "availabilityCondition": "answered and credit=1", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}, {"label": "Sample size hint", "rawLabel": "", "otherPart": 8, "variableReplacements": [], "availabilityCondition": "answered and credit<1", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": "Sample size", "prompt": "

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 bar chart, then compare the bar chart with known statistical distributions.

\n

How 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": "Bar Chart Bins", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "numberInRange (Is the student's number in the allowed range?):\n if(studentNumber>=minvalue and studentNumber<=maxvalue and isInteger and gcd({binsNumber},studentNumber)=studentNumber,\n correct(\"Try this number of bins and examine the bar chart. You can return to this part if you want to try a different number.\")\n ,\n if(gcd(studentNumber,{binsNumber})<>studentNumber and isInteger,\n incorrect(\"This many bins won't give you a good idea of the distribution shape. Try a value that is a factor of the range + 1.\"),\n if(studentNumber>maxvalue and isInteger,\n incorrect(\"This many bins may mean that you lose the shape of the distribution and just show individual observations. Try a value less than the range.\"),\n incorrect(\"The number of bins needs to be an integer.\")));\n end()\n )\n\nmark:\n apply(validNumber);\n apply(numberInRange);\n assert(numberInRange,end());\n if(isFraction,\n apply(cancelled)\n ,\n apply(correctPrecision)\n )\n\ninterpreted_answer (The student's answer, to be reused by other parts):\n apply(validNumber);\n studentNumber\n", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": false, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [{"label": "Show the bar chart for the sample", "rawLabel": "Show the bar chart for the sample", "otherPart": 2, "variableReplacements": [{"variable": "binsNumber", "definition": "int(interpreted_answer)"}], "availabilityCondition": "answered and credit=1", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}, {"label": "Bar Chart bins hint", "rawLabel": "", "otherPart": 9, "variableReplacements": [], "availabilityCondition": "answered and credit<1", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": "Histogram bins", "prompt": "

You have decided to collect a sample consisting of \\(\\var{n}\\) observations. The smallest observation is \\(\\var{sampleMin}\\) and the largest is \\(\\var{sampleMax}\\). Because this is a discrete variable it is convenient to have bin widths which are a whole number. this means that the number of bins needs to be a factor of one more than the range, eg if the range is $7$ then the number of bins needs to be a factor of $8$.

", "minValue": "1", "maxValue": "{binsNumber}", "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": "Bar Chart", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [{"label": "Superimpose a Poisson distribution over the bar chart", "rawLabel": "Superimpose a Poisson distribution over the bar chart", "otherPart": 3, "variableReplacements": [], "availabilityCondition": "", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}, {"label": "Superimpose a uniform distribution over the bar chart", "rawLabel": "Superimpose a uniform distribution over the bar chart", "otherPart": 4, "variableReplacements": [], "availabilityCondition": "", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}, {"label": "Superimpose a binomial distribution over the bar chart", "rawLabel": "Superimpose a binomial distribution over the bar chart", "otherPart": 5, "variableReplacements": [], "availabilityCondition": "", "penalty": "", "penaltyAmount": 0, "showPenaltyHint": true, "lockAfterLeaving": false}], "suggestGoingBack": true, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "\n

Here is a bar chart 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 bar chart use the \"Go back to previous part\" link below.

\n

{visSelected}

\n

"}, {"type": "information", "useCustomName": true, "customName": "Poisson", "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": "

{poissonDist}

\n

To see a different distribution superimposed on the bar chart select \"Go back to previous part\" below.

"}, {"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}

\n

To see a different distribution superimposed on the bar chart select \"Go back to previous part\" below.

"}, {"type": "information", "useCustomName": true, "customName": "Binomial", "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": "

{binomDist}

\n

To see a different distribution superimposed on the bar chart select \"Go back to previous part\" below.

"}, {"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", "Binomial distribution", "Poisson 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}

\n

Mean 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": "Bar Chart 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 bar chart needs to be an integer, we can't have a fraction of a bin. Since we are investigating a discrete distibution, the number of bins should be a factor of the range of the data plus one, that is a factor of \\(\\var{sampleMax-sampleMin+1}\\).

"}], "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", "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/"}]}