// Numbas version: exam_results_page_options {"name": "Blathnaid's copy of mathcentre: Methods of sampling", "feedback": {"allowrevealanswer": true, "showtotalmark": true, "advicethreshold": 0, "intro": "", "feedbackmessages": [], "showanswerstate": true, "showactualmark": true}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "allQuestions": true, "shuffleQuestions": false, "percentPass": 0, "duration": 0, "pickQuestions": 0, "navigation": {"onleave": {"action": "none", "message": ""}, "reverse": true, "allowregen": true, "showresultspage": "oncompletion", "preventleave": false, "browse": true, "showfrontpage": false}, "metadata": {"description": "

4 questions. Qualitative, quantitative random variables, types of sampling, frequencies, stem and leaf plot, descriptive statistics.

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "exam", "questions": [], "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": [{"name": "Blathnaid's copy of BS1.1", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Blathnaid Sheridan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/447/"}], "functions": {}, "tags": ["qualitative variables", "quantitative variables", "random variables", "statistics"], "advice": "", "rulesets": {}, "parts": [{"maxanswers": 0.0, "matrix": "m", "shuffleanswers": true, "minanswers": 0.0, "shufflechoices": true, "answers": ["Qualitative", "Quantitative"], "choices": ["{ch1}", "{ch2}", "{ch3}"], "displaytype": "radiogroup", "maxmarks": 0.0, "marks": 1.0, "type": "m_n_x", "minmarks": 0.0}], "statement": "\n

State whether the following variables are Qualitative or Quantitative. 

\n

Note that you will be deducted one mark for every wrong choice. However the minimum mark is 0.

\n ", "variable_groups": [], "progress": "testing", "type": "question", "variables": {"quant1": {"definition": "[\"The number of orders received by a catering company\",\"The height of students taking Statistics courses at Newcastle this year\", \"Your quarterly gas bill\", \"The time spent on hold at a credit call centre\",\"The average shipping time for orders placed with a TV shopping channel\",\"The annual electricity bill for a large UK Supermarket\"]", "name": "quant1"}, "quant2": {"definition": "[\"The number of people requiring a special in-flight meal\",\"The average volume of bottles of wine imported from South America\",\"Salaries of Newcastle University graduates six months after graduation\",\"The distance travelled by taxis for a particular cab firm every day\",\"Total annual sales for a large American departmental store\",\"The total cost of a student's text books for this semester\"]", "name": "quant2"}, "qual2": {"definition": "[\"Ice cream flavour preferred by children\",\"Brand of sportswear preferred by athletes\",\"Favourite type of film by UK cinema-goers\",\"Mobile phone price-plan\",\"Shape of swimming pools in local authority-run leisure centres\"]", "name": "qual2"}, "cind": {"definition": "-1*ind1", "name": "cind"}, "qual1": {"definition": "[\"Types of PC used by small businesses in the north-east\",\"Marital status of questionnaire respondents\",\"Month of the year in which small shops record their highest sales\",\"Type of tenure for those in the licensed trade business\",\"Subjects studied at A level by students in this class\"]", "name": "qual1"}, "m": {"definition": "transpose(matrix(list(cind),list(ind1)))", "name": "m"}, "ch1": {"definition": "switch(ind[0]=0,random(qual),random(quant))", "name": "ch1"}, "ch2": {"definition": "switch(ind[1]=0,random(qual except ch1),random(quant except ch1))", "name": "ch2"}, "ch3": {"definition": "switch(ind[2]=0,random(qual except [ch1,ch2]),random(quant except [ch1,ch2]))", "name": "ch3"}, "quant": {"definition": "quant1+quant2", "name": "quant"}, "ind": {"definition": "random([[0,0,0],[1,0,0],[0,1,0],[0,0,1],[0,1,1],[1,0,1],[1,1,0],[1,1,1]])", "name": "ind"}, "ind1": {"definition": "2*vector(ind)-vector(1,1,1)", "name": "ind1"}, "qual": {"definition": "qual1+qual2", "name": "qual"}}, "metadata": {"notes": "", "description": "

Choosing whether given random variables are qualitiative or quantitative.

", "licence": "Creative Commons Attribution 4.0 International"}, "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "BS1.3", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}], "functions": {"revsort": {"definition": "list(-1*vector(sort(list(-1*vector(a)))))", "type": "list", "language": "jme", "parameters": [["a", "list"]]}}, "tags": ["frequencies", "percentages", "relative percentage frequencies", "statistics"], "advice": "\n

We show how to calculate the relative percentage frequency for one range of values for  $\\var{a[r]} \\le X \\lt \\var{a[r+1]}$    - you can then check the rest.

\n

Note that there were $\\var{daysopen}$ days  in the year when sales took place. 

\n

There were $\\var{norm1[r]}$ days out of the  $\\var{daysopen}$ when there were between $\\var{a[r]}$ and $\\var{a[r+1]}$ thousand pounds worth of sales (including  $\\var{a[r]}$ thousand but not $\\var{a[r+1]}$ thousand) .

\n

Hence the relative frequency percentage for such sales is given by \\[100 \\times \\frac{\\var{norm1[r]}}{\\var{daysopen}}\\%=\\var{rel[r]}\\%\\] to one decimal place.

\n

 

\n ", "rulesets": {}, "parts": [{"prompt": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
{things} {num} Relative Percentages
$\\var{a[0]}\\le X \\lt \\var{a[1]}$$\\var{norm1[0]}$[[0]]
$\\var{a[1]}\\le X \\lt \\var{a[2]}$$\\var{norm1[1]}$[[1]]
$\\var{a[2]}\\le X \\lt \\var{a[3]}$$\\var{norm1[2]}$[[2]]
$\\var{a[3]}\\le X \\lt \\var{a[4]}$$\\var{norm1[3]}$[[3]]
$\\var{a[4]}\\le X \\lt \\var{a[5]}$$\\var{norm1[4]}$[[4]]
$\\var{a[5]}\\le X \\lt \\var{a[6]}$$\\var{norm1[5]}$[[5]]
$\\var{a[6]}\\le X \\lt \\var{a[7]}$$\\var{norm1[6]}$[[6]]
\n ", "gaps": [{"minvalue": "rel[0]", "type": "numberentry", "maxvalue": "rel[0]", "marks": 1.0, "showPrecisionHint": false}, {"minvalue": "rel[1]", "type": "numberentry", "maxvalue": "rel[1]", "marks": 1.0, "showPrecisionHint": false}, {"minvalue": "rel[2]", "type": "numberentry", "maxvalue": "rel[2]", "marks": 1.0, "showPrecisionHint": false}, {"minvalue": "rel[3]", "type": "numberentry", "maxvalue": "rel[3]", "marks": 1.0, "showPrecisionHint": false}, {"minvalue": "rel[4]", "type": "numberentry", "maxvalue": "rel[4]", "marks": 1.0, "showPrecisionHint": false}, {"minvalue": "rel[5]", "type": "numberentry", "maxvalue": "rel[5]", "marks": 1.0, "showPrecisionHint": false}, {"minvalue": "rel[6]", "type": "numberentry", "maxvalue": "rel[6]", "marks": 1.0, "showPrecisionHint": false}], "type": "gapfill", "marks": 0.0}], "statement": "\n

The following table shows {what}, $X$, {units} {forwhat}.

\n

Calculate the relative percentage frequencies (to one decimal place for all).

\n ", "variable_groups": [], "progress": "testing", "type": "question", "variables": {"a": {"definition": "map(s*x,x,0..7)", "name": "a"}, "what": {"definition": "'daily sales'", "name": "what"}, "freqdays": {"definition": "freqdays1+freqdays2", "name": "freqdays"}, "daysopen": {"definition": "sum(norm1)", "name": "daysopen"}, "things": {"definition": "'Sales'", "name": "things"}, "m": {"definition": "max(freqdays1)", "name": "m"}, "forwhat": {"definition": "'for a large retailer in '+random(2010,2011,2012)", "name": "forwhat"}, "units": {"definition": "'in thousands of pounds'", "name": "units"}, "s": {"definition": "random(5..15#5)", "name": "s"}, "num": {"definition": "'Number of days'", "name": "num"}, "rel": {"definition": "map(precround(100*norm1[x]/daysopen,1),x,0..2*n1-2)", "name": "rel"}, "n1": {"definition": 4.0, "name": "n1"}, "y": {"definition": "random(300..320)", "name": "y"}, "freqdays1": {"definition": "sort(repeat(random(2..50),n1))", "name": "freqdays1"}, "freqdays2": {"definition": "revsort(repeat(random(2..m-1),n1-1))", "name": "freqdays2"}, "r": {"definition": "random(0..5)", "name": "r"}, "norm1": {"definition": "map(round(x),x,list((y/sum(freqdays))*vector(freqdays)))", "name": "norm1"}}, "metadata": {"notes": "", "description": "

Given a table of the number of days in which sales were between £x1000 and £(x+1)1000 find the relative percentage frequencies of these volume of sales.

", "licence": "Creative Commons Attribution 4.0 International"}, "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Blathnaid's copy of BS1.5", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Blathnaid Sheridan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/447/"}], "functions": {"lquartile": {"definition": "\n interpolate(a,(length(a)+1)/4)", "type": "number", "language": "jme", "parameters": [["a", "list"]]}, "uquartile": {"definition": "interpolate(a,3*(length(a)+1)/4)", "type": "number", "language": "jme", "parameters": [["a", "list"]]}, "interpolate": {"definition": "(1-fract(r))*sort(a)[floor(r)-1]+fract(r)*sort(a)[ceil(r)-1]", "type": "number", "language": "jme", "parameters": [["a", "list"], ["r", "number"]]}, "flattenint": {"definition": "\n /*only for integer arrays*/ \n array.toString().split(',').forEach( function (item, i) \n {array[i] = parseInt(item);\n }\n ); \n return array;\n ", "type": "list", "language": "javascript", "parameters": [["array", "list"]]}}, "tags": ["interquartile range", "lower quartile", "mean", "median", "ordered data", "sample data", "sample mean", "sample standard deviation", "sc", "statistics", "udf", "upper quartile"], "advice": "\n

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

 

\n ", "rulesets": {}, "parts": [{"prompt": "\n

Sample mean = [[0]]{shortform}. Give your answer to  $2$ decimal places.

\n

Sample Standard Deviation = [[1]] {shortform}. Give your answer to $2$ decimal places.

\n

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

\n

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

\n ", "gaps": [{"minvalue": "av-0.01", "type": "numberentry", "maxvalue": "av+0.01", "marks": 1.0, "showPrecisionHint": false}, {"minvalue": "std-0.01", "type": "numberentry", "maxvalue": "std+0.01", "marks": 1.0, "showPrecisionHint": false}, {"minvalue": "med", "type": "numberentry", "maxvalue": "med", "marks": 1.0, "showPrecisionHint": false}, {"minvalue": "interq", "type": "numberentry", "maxvalue": "interq", "marks": 1.0, "showPrecisionHint": false}], "type": "gapfill", "marks": 0.0}], "statement": "\n

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

\n

{table(tble,t)}

\n

Answer the following questions:

\n

 

\n

 

\n ", "variable_groups": [], "progress": "testing", "type": "question", "variables": {"me": {"definition": "random(7..12)", "name": "me"}, "tble1": {"definition": "repeat(repeat(max(round(normalsample(me,sig)),random(4..6)),m),n)", "name": "tble1"}, "tble": {"definition": "switch(n=2,map(['Year '+x+':']+tble1[x-1],x,1..2),map(['Week '+ x+':']+tble1[x-1],x,1..3))", "name": "tble"}, "shortform": {"definition": "'orders'", "name": "shortform"}, "med": {"definition": "median(r)", "name": "med"}, "this": {"definition": "'an online warehouse' ", "name": "this"}, "m": {"definition": "if(n=2,12,random(7,5))", "name": "m"}, "period": {"definition": "switch(m=7,'day',m=12,'month',m=5,'weekday')", "name": "period"}, "whatever": {"definition": "'number of orders per ' + period", "name": "whatever"}, "interq": {"definition": "precround(uquartile(r)-lquartile(r),2)", "name": "interq"}, "note": {"definition": "if(mean(r)=av,' ','Note that we used the more accurate value $(\\\\var{mean(r)})^2$ for $\\\\bar{x}^2$.')", "name": "note"}, "p": {"definition": "switch(m=12,'year','week')", "name": "p"}, "std": {"definition": "precround(stdev(r,true),2)", "name": "std"}, "r": {"definition": "flattenint(tble1)", "name": "r"}, "these": {"definition": "'specialist camera equipment'", "name": "these"}, "t": {"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'])", "name": "t"}, "av": {"definition": "precround(mean(r),2)", "name": "av"}, "units": {"definition": "'over a '+ n + ' '+p+ ' period,'", "name": "units"}, "sig": {"definition": "random(2..4#0.2)", "name": "sig"}, "n": {"definition": "random(2,3)", "name": "n"}}, "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.

", "description": "

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

\n

Note that there are different versions of the upper and lower quartiles, so you may want to include your own versions - see the user defined functions in the question.

", "licence": "Creative Commons Attribution 4.0 International"}, "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}]}], "contributors": [{"name": "Blathnaid Sheridan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/447/"}], "extensions": ["stats"], "custom_part_types": [], "resources": []}