// Numbas version: finer_feedback_settings {"name": "Maths Support: Methods of sampling", "navigation": {"onleave": {"action": "none", "message": ""}, "reverse": true, "allowregen": true, "preventleave": false, "browse": true, "showfrontpage": false, "showresultspage": "never"}, "duration": 0, "metadata": {"notes": "", "description": "

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

", "licence": "Creative Commons Attribution 4.0 International"}, "allQuestions": true, "shuffleQuestions": false, "questions": [], "percentPass": 0, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "pickQuestions": 0, "type": "exam", "feedback": {"showtotalmark": true, "advicethreshold": 0, "showanswerstate": true, "showactualmark": true, "allowrevealanswer": true, "enterreviewmodeimmediately": false, "showexpectedanswerswhen": "never", "showpartfeedbackmessageswhen": "always", "showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showadvicewhen": "never"}, "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": [{"name": "BS1.1", "extensions": [], "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": {}, "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.2", "extensions": [], "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": {}, "tags": ["judgemental sampling", "non-random sampling", "quasi-random sampling", "random", "sample", "sampling methods", "simple random sampling", "statistics", "stratified sampling", "systematic sampling"], "type": "question", "advice": "", "rulesets": {}, "parts": [{"maxanswers": 0.0, "prompt": "\n

Identify each of the following scenarios as one of the following:

\n\n

Note that you will lose 1 mark for every incorrect answer, however the least mark for this part of the question is 0.

\n

 

\n", "matrix": "w", "shuffleanswers": false, "minanswers": 0.0, "shufflechoices": false, "answers": ["Simple Random Sampling", "Stratified Sampling", "Systematic Sampling", "Judgemental Sampling"], "choices": ["{ch1}", "{ch2}", "{ch3}"], "displaytype": "radiogroup", "maxmarks": 0.0, "marks": 1.0, "type": "m_n_x", "minmarks": 0.0}, {"maxanswers": 0.0, "prompt": "\n

For each choice, state whether the form of the sampling described is random, quasi-random or non-random.

\n

As before, you will lose 1 mark for every incorrect answer, however the least mark for this part of the question is 0.

\n", "matrix": "v", "shuffleanswers": true, "minanswers": 0.0, "shufflechoices": false, "answers": ["Random", "Quasi-Random", "Non-random"], "choices": ["{ch1}", "{ch2}", "{ch3}"], "displaytype": "radiogroup", "maxmarks": 0.0, "marks": 1.0, "type": "m_n_x", "minmarks": 0.0}], "statement": "\n

Answer the following questions on the sampling methods used in these situations.

\n

 

\n", "variable_groups": [], "progress": "testing", "preamble": {"css": "", "js": ""}, "variables": {"a": {"definition": "[\"One hundred small businesses in Newcastle are placed in alphabetical order and then numbered 1-100. The random number generator is then used to select twenty of these businesses.\",\"Under this form of sampling, if there are five hundred elements in the population, each element has a one-in-five hundred chance of being selected. \",\"One advantage of this form of sampling is that every element in the population has an equal chance of being selected.\",\"We are interested in the employment status of 25-40 year olds in South Tyneside. The names of all such people are obtained from the electoral roll and put into a hat; one hundred of these are then selected without replacement.\",\"One of six branches of a large retail outlet is to be selected for an audit. Each outlet is assigned a number from one to six, and then a fair, six-sided die is rolled to select the branch which will be audited.\"]", "name": "a"}, "c": {"definition": "[\"The first item to be checked for faults on a production line is chosen at random, thereafter, every 100th item is checked.\",\"A credit card company wants to investigate the spending habits if its customers. From its lists, the first customer is selected at random; thereafter, every 25th customer is selected.\",\"In an inquiry on heating costs, we decide to sample every 4th house on the street.\",\"To sample 1% of its target population, consisting of 5000 members, a market research company chooses the first member at random; after that, every 100th member is also selected.\",\"This form of sampling could produce an unrepresentative sample because of patterns in the sampling frame.\"]", "name": "c"}, "b": {"definition": "[\"A local bus company is planning a new route to serve four housing estates. Random samples of households are taken from each estate and sample members are asked to rate on a scale of 1 (strongly opposed) to 5 (strongly in favour) their reaction to the proposed service.\",\"A company has three divisions, and auditors are attempting to estimate the total amounts of the company's accounts receivable. Simple random samples of these accounts were taken for each of the three divisions.\",\"A company has three divisions, and auditors are attempting to estimate the total amounts of the company's accounts receivable. Simple random samples of these accounts were taken for each of the three divisions.\",\"This form of sampling reflects the major groupings within a population.\"]", "name": "b"}, "d": {"definition": "[\"A company director believes she knows what characteristics make up the target population for a new product her company intends to launch. The company's team of market researchers check the viability of this new product by eliciting the opinions of the target population as specified by the director.\",\"Specific members of a population are sampled because of their known honesty and integrity.\",\"This form of sampling can provide a coherent and focussed sample by asking people with experience and relevant knowledge to provide their opinions.\",\"With this form of sampling, the researcher decides what he or she constitutes a representative sample.\"]", "name": "d"}, "chlist": {"definition": "repeat(random(0,1,2,3),3)", "name": "chlist"}, "ch1": {"definition": "switch(chlist[0]=0,random(a),chlist[0]=1,random(b),chlist[0]=2,random(c),random(d))", "name": "ch1"}, "ch2": {"definition": "switch(chlist[1]=0,random(a except ch1),chlist[1]=1,random(b except ch1),chlist[1]=2,random(c except ch1),random(d except ch1))", "name": "ch2"}, "ch3": {"definition": "switch(chlist[2]=0,random(a except [ch1,ch2]),chlist[2]=1,random(b except [ch1,ch2]),chlist[2]=2,random(c except [ch1,ch2]),random(d except [ch1,ch2]))", "name": "ch3"}, "w": {"definition": "map(switch(chlist[x]=0,[1,-1,-1,-1],chlist[x]=1,[-1,1,-1,-1],chlist[x]=2,[-1,-1,1,-1],[-1,-1,-1,1]),x,0..2)", "name": "w"}, "v": {"definition": "map(switch(chlist[x]=0,[1,-1,-1],chlist[x]=1,[1,-1,-1],chlist[x]=2,[-1,1,-1],[-1,-1,1]),x,0..2)", "name": "v"}}, "metadata": {"notes": "", "description": "

Deciding whether or not  three sampling methods are simple random sampling, stratified sampling, systematic or judgemental sampling. Also whether or not the method of selection is random, quasi-random or non-random.

", "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": "BS1.5", "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": {"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": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "extensions": ["stats"], "custom_part_types": [], "resources": []}