// Numbas version: exam_results_page_options {"name": "Find mean, standard deviation, median and interquartile range of sample, ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "variables": {"av": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r),2)", "description": "", "name": "av"}, "sig": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..4#0.2)", "description": "", "name": "sig"}, "std": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stdev(r,true),2)", "description": "", "name": "std"}, "these": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'specialist camera equipment'", "description": "", "name": "these"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(n=2,12,random(7,5))", "description": "", "name": "m"}, "this": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'an online warehouse' ", "description": "", "name": "this"}, "med": {"templateType": "anything", "group": "Ungrouped variables", "definition": "median(r)", "description": "", "name": "med"}, "tble1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(repeat(max(round(normalsample(me,sig)),random(4..6)),m),n)", "description": "", "name": "tble1"}, "whatever": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'number of orders per ' + period", "description": "", "name": "whatever"}, "interq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(uquartile(r)-lquartile(r),2)", "description": "", "name": "interq"}, "shortform": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'orders'", "description": "", "name": "shortform"}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "flattenint(tble1)", "description": "", "name": "r"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2,3)", "description": "", "name": "n"}, "tble": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(n=2,map(['Year '+x+':']+tble1[x-1],x,1..2),map(['Week '+ x+':']+tble1[x-1],x,1..3))", "description": "", "name": "tble"}, "units": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'over a '+ n + ' '+p+ ' period,'", "description": "", "name": "units"}, "note": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(mean(r)=av,' ','Note that we used the more accurate value $(\\\\var{mean(r)})^2$ for $\\\\bar{x}^2$.')", "description": "", "name": "note"}, "me": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(7..12)", "description": "", "name": "me"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(m=12,'year','week')", "description": "", "name": "p"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(m=12,[' ','J','F','M','A','M','J','J','A','S','O','N','D'],m=5,[' ','M','T','W','T','F'],[' ','M','T','W','T','F','S','S'])", "description": "", "name": "t"}, "period": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(m=7,'day',m=12,'month',m=5,'weekday')", "description": "", "name": "period"}}, "ungrouped_variables": ["me", "tble1", "tble", "p", "shortform", "med", "this", "m", "interq", "whatever", "n", "note", "these", "std", "r", "sig", "t", "av", "units", "period"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "name": "Find mean, standard deviation, median and interquartile range of sample, ", "functions": {"flattenint": {"type": "list", "language": "javascript", "definition": "/*only for integer arrays*/ \n array.toString().split(',').forEach( function (item, i) \n {array[i] = parseInt(item);\n }\n ); \n return array;", "parameters": [["array", "list"]]}, "uquartile": {"type": "number", "language": "jme", "definition": "interpolate(a,3*(length(a)+1)/4)", "parameters": [["a", "list"]]}, "interpolate": {"type": "number", "language": "jme", "definition": "(1-fract(r))*sort(a)[floor(r)-1]+fract(r)*sort(a)[ceil(r)-1]", "parameters": [["a", "list"], ["r", "number"]]}, "lquartile": {"type": "number", "language": "jme", "definition": "interpolate(a,(length(a)+1)/4)", "parameters": [["a", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"prompt": "

Sample mean = [[0]]{shortform}. Give your answer to  $2$ decimal places (include trailing zeros if required).

\n

Sample Standard Deviation = [[1]] {shortform}. Give your answer to $2$ decimal places (include trailing zeros if required).

\n

Sample Median = [[2]] (Input as an exact decimal).

\n

The interquartile range= [[3]] (Input as an exact decimal).

", "scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "av-0.01", "maxValue": "av+0.01", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 1}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "std-0.01", "maxValue": "std+0.01", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 1}, {"correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "allowFractions": false, "type": "numberentry", "maxValue": "med", "minValue": "med", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "showPrecisionHint": false}, {"correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "allowFractions": false, "type": "numberentry", "maxValue": "interq", "minValue": "interq", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0}], "statement": "

The following data are the {whatever} for {these}, {units} taken by {this}

\n

{table(tble,t)}

\n

Answer the following questions:

\n

 

\n

 

", "tags": ["ACE2013", "checked2015", "interquartile range", "lower quartile", "MAS1403", "mean", "mean ", "median", "quartiles", "sample data", "sample mean", "sample standard deviation", "standard deviation", "statistics", "upper quartile"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

Note that the uquartile and lquartile are calculated as given by the functions below these may change!

\n

 21/12/2012:

\n

Three user defined functions. Added tag udf.

\n

flattenint, takes an array of arrays with integers leaves and converts to an integer array by flattening the array. Other two functions, uquartile and lquartile find the lower and upper quartiles.

\n

Scenarios possible, added sc.

\n

22/10/2013:

\n


Redefined functions uquartile and lquartile to fit new definitions. Added helper udf interpolate.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Given sample data find mean, standard deviation, median, interquartile range,

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

As we have to find the median and the interquartile range it is a good idea to order the data and also to total up the data (for the mean) and find the total of the squares of the data (for the variance).

\n

{table([['Data']+sort(r),['Squared data']+map(x^2,x,sort(r)),['Index']+map(x,x,1..m*n)],[])}

\n

Note that from the above table:

\n

$n=\\var{m*n}$.

\n

$\\displaystyle  \\sum x_i = \\var{sum(r)}$ and 

\n

$\\displaystyle  \\sum x^2_i = \\var{sum(map(x^2,x,r))}$ .

\n

The sample mean is $\\bar{x}=\\displaystyle \\frac{ \\sum x_i}{n}=\\frac{\\var{sum(r)}}{\\var{m*n}}=\\var{mean(r)}=\\var{av}$ to 2 decimal places.

\n

The sample deviation is the square root of the sample variance.

\n

Sample variance:\\[\\begin{eqnarray*}\\frac{1}{ n -1}\\left(\\sum x_i ^ 2 - n \\bar{x} ^ 2\\right)&=& \\frac{1}{\\var{m*n-1}}\\left(\\var{sum(map(x^2,x,r))}-\\var{m*n}\\times\\var{mean(r)^2}\\right)\\\\&=&\\var{variance(r,true)}\\end{eqnarray*}\\] {Note} 

\n

So the sample standard deviation = $\\sqrt{\\var{variance(r,true)}}=\\var{std}$ to 2 decimal places.

\n

The median is $\\var{median(r)} $.

\n

The lower quartile is : $\\var{lquartile(r)}$.

\n

The upper quartile is : $\\var{uquartile(r)}$.

\n

The interquartile range is the difference between these quartiles =$\\var{uquartile(r)}-\\var{lquartile(r)}=\\var{uquartile(r)-lquartile(r)}$

\n

 

\n

 

", "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}