// Numbas version: exam_results_page_options {"name": "Computing for Mathematics Examples", "metadata": {"description": "Some examples of Numbas questions used in computing modules in the School of Mathematics, Statistics & Physics at Newcastle University", "licence": "Creative Commons Attribution 4.0 International"}, "duration": 0, "percentPass": 0, "showQuestionGroupNames": true, "showstudentname": true, "question_groups": [{"name": "R", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", ""], "questions": [{"name": "Querying a data frame (TV set)", "extensions": ["json_from_file", "stats"], "custom_part_types": [], "resources": [["question-resources/tv_u1CHb9S.json", "/srv/numbas/media/question-resources/tv_u1CHb9S.json"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Chris Graham", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/73/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}], "tags": [], "metadata": {"description": "

This question takes in a json file containing a tv data frame in the R package ncldata (https://rdrr.io/rforge/ncldata/). 

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

Run the following commands to load the tv data frame:

\n
install.packages(\"ncldata\", repos=\"http://R-Forge.R-project.org\")
library(ncldata)
data(tv)
\n

Take a look at the help for the data frame with:

\n
help(tv)
\n

", "advice": "

a)

\n

The dimensions of the data frame can be found with the function dim

\n
dim(tv)
\n

Or individually, the number of rows and columns can be found with

\n
nrow(tv)
ncol(tv)
\n

b)

\n

The row with a title {random_prog['Title']} can be isolated with

\n
tv[tvTitle=='{random_prog['Title']}',]
\n

Note the capital T for the column title. If you aren't sure about the column names use

\n
colnames(tv)
\n

We can either read off the rating, or we can isolate the value using the $ notation

\n
tv[tvTitle=='{random_prog['Title']}',]$Rating
\n

c)

\n

Following the method in part b),

\n
tv[tvTitle=='{random_prog2['Title']}',]$Votes
\n

d)

\n

Using the square bracket notation above, the subset of tv shows with a start year greater than or equal to {year} can be found with

\n
tv[tvStartYear >= {year},]
\n

Or, using the function subset,

\n
subset(tv,StartYear >= {year})
\n

We can use nrow to find the number of tv shows in the subset, either by assigning the above to a new data frame, or querying it directly:

\n
nrow(subset(tv,StartYear >= {year}))
\n

e)

\n

The subset of TV shows which both started and ended in the {1900+(decade*10)}s can be found with

\n
subset(tv,StartYear >={1900+(decade*10)} & EndYear <={1909+(decade*10)})
\n

Again, nrow can be used to find the number of shows in this subset.

\n

f)

\n

The subset of TV shows which started and ended in the same year, but have a rating greater than {random_rating} is

\n
subset(tv,StartYear == EndYear & Rating > {random_rating})
\n

g)

\n

The mean rating of TV shows which started have started since (and including) {year2} can be found with

\n
mean(subset(tv,StartYear >= {year2})$Rating)
\n

h)

\n

The subset of TV shows which are exactly {random_length} minutes long can be found with

\n
subset(tv, Length=={random_length})
\n

Note that for this example, you will find a different (and incorrect) answer if you use square brackets to subset. Take a look at the output of the following command to see the problem:

\n
tv[tvLength == {random_length},]$Length
", "rulesets": {}, "variables": {"year2": {"name": "year2", "group": "Ungrouped variables", "definition": "random(2011..2017)", "description": "", "templateType": "anything"}, "random_prog_id": {"name": "random_prog_id", "group": "Ungrouped variables", "definition": "random(20..length(getTVEnded()))", "description": "", "templateType": "anything"}, "tv_in_decade": {"name": "tv_in_decade", "group": "Ungrouped variables", "definition": "len(filter(prog[\"StartYear\"] >= 1900+(decade*10) and prog[\"EndYear\"] <= 1909+(decade*10),prog,getTVEnded()))", "description": "", "templateType": "anything"}, "columns_in_data": {"name": "columns_in_data", "group": "Ungrouped variables", "definition": "len(getTVData()[1])-1", "description": "", "templateType": "anything"}, "random_prog": {"name": "random_prog", "group": "Ungrouped variables", "definition": "getTVEnded()[random_prog_id-1]", "description": "", "templateType": "anything"}, "one_year_shows": {"name": "one_year_shows", "group": "Ungrouped variables", "definition": "len(filter(prog[\"Rating\"] > random_rating and (prog[\"StartYear\"] = prog[\"EndYear\"]),prog,getTVEnded()))", "description": "", "templateType": "anything"}, "random_prog_id2": {"name": "random_prog_id2", "group": "Ungrouped variables", "definition": "random(20..length(getTVEnded()) except random_prog_id)", "description": "", "templateType": "anything"}, "rows_in_data": {"name": "rows_in_data", "group": "Ungrouped variables", "definition": "len(getTVData())", "description": "", "templateType": "anything"}, "rating_since_year": {"name": "rating_since_year", "group": "Ungrouped variables", "definition": "mean(map(prog[\"Rating\"],prog,filter(prog[\"StartYear\"]>=year2,prog,getTVData())))", "description": "", "templateType": "anything"}, "random_rating": {"name": "random_rating", "group": "Ungrouped variables", "definition": "random(5..9)", "description": "", "templateType": "anything"}, "random_length": {"name": "random_length", "group": "Ungrouped variables", "definition": "random(20..90#10)", "description": "", "templateType": "anything"}, "tv_exact_length": {"name": "tv_exact_length", "group": "Ungrouped variables", "definition": "length(filter(prog[\"Length\"]=random_length,prog,getTVData()))", "description": "", "templateType": "anything"}, "decade": {"name": "decade", "group": "Ungrouped variables", "definition": "random(6..9)", "description": "", "templateType": "anything"}, "category2": {"name": "category2", "group": "Movie Categories", "definition": "categories[1]", "description": "", "templateType": "anything"}, "random_prog2": {"name": "random_prog2", "group": "Ungrouped variables", "definition": "getTVEnded()[random_prog_id2-1]", "description": "", "templateType": "anything"}, "tv_after_year": {"name": "tv_after_year", "group": "Ungrouped variables", "definition": "length(filter(prog[\"StartYear\"]>=year,prog,getTVData()))", "description": "", "templateType": "anything"}, "category1": {"name": "category1", "group": "Movie Categories", "definition": "categories[0]", "description": "", "templateType": "anything"}, "year": {"name": "year", "group": "Ungrouped variables", "definition": "random(1990..2017)", "description": "", "templateType": "anything"}, "categories": {"name": "categories", "group": "Movie Categories", "definition": "shuffle([\"Action\", \"Animation\", \"Comedy\", \"Drama\", \"Documentary\", \"Romance\"])", "description": "

The 7 movie categories in the data frame

", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["year", "year2", "random_prog_id", "random_prog_id2", "random_length", "decade", "random_rating", "tv_after_year", "rows_in_data", "columns_in_data", "tv_in_decade", "random_prog", "one_year_shows", "rating_since_year", "tv_exact_length", "random_prog2"], "variable_groups": [{"name": "Movie Categories", "variables": ["categories", "category1", "category2"]}], "functions": {"getTVData": {"parameters": [], "type": "list", "language": "jme", "definition": "json_from_file('resources/question-resources/tv_u1CHb9S.json')"}, "getTVEnded": {"parameters": [], "type": "list", "language": "jme", "definition": "filter(tv['EndYear']<>'NA',tv,getTVData())"}}, "preamble": {"js": "question.signals.on('HTMLAttached',function() {\n $(\"span.dollar\").html(\"$\");\n});", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many rows and columns are there in the tv data frame?

\n

Rows: [[0]]

\n

Columns: [[1]]

", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "minValue": "rows_in_data", "maxValue": "rows_in_data", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "minValue": "columns_in_data", "maxValue": "columns_in_data", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

What is the average rating of the TV show {random_prog['Title']}?

", "minValue": "random_prog['Rating']", "maxValue": "random_prog['Rating']", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many people have voted on the rating of the TV show {random_prog2['Title']}?

", "minValue": "random_prog2['Votes']", "maxValue": "random_prog2['Votes']", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many of the TV programmes have a start year of {year} or later?

\n

", "minValue": "tv_after_year", "maxValue": "tv_after_year", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many of the TV shows started and ended in the same year, but have a rating greater than {random_rating}?

", "minValue": "one_year_shows", "maxValue": "one_year_shows", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many of the TV shows both started and ended in the {1900+(decade*10)}s?

", "minValue": "tv_in_decade", "maxValue": "tv_in_decade", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

What is the mean rating of TV shows which have started since (and including) {year2}?

", "minValue": "rating_since_year", "maxValue": "rating_since_year", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many TV shows are exactly {random_length} minutes long?

", "minValue": "tv_exact_length", "maxValue": "tv_exact_length", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}]}, {"name": "Query file with random data in R ", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Chris Graham", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/73/"}, {"name": "Keith Newman", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/126/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}], "tags": [], "metadata": {"description": "

Download a file and scan the values into R to obtain a numeric vector of values. Then use R to explore your numeric vector in order to find the answers to these questions.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

Follow the below steps to download a file of numeric values and to read it into R

\n
    \n
  1. {download_values(list(tumbleVector(seed,vec_length,-99999,99999)/1000))}. The downloaded file should be called numeric.txt and contains a list of numbers, with one number on each line of the file. Save or move the file somewhere sensible, for example into a folder called \"Practical 1\", within your \"MAS1802\" folder
  2. \n
  3. Now make sure that RStudio is in the same working directory as the file you have just saved. You can change the working directory by going to Session in the menu, Set Working Directory and then Choose Directory...
  4. \n
  5. Use the following command to store the data in a numeric vector v.
  6. \n
\n
v = scan(\"numeric.txt\")
\n

Before you begin, check that the first few values of v match the first few rows in the file.

\n

When giving the values of vector elements, do not round your answers.

", "advice": "

Solutions/feedback will be given in classes after the assessment period.

", "rulesets": {}, "variables": {"seed": {"name": "seed", "group": "Ungrouped variables", "definition": "random(1..1000)", "description": "", "templateType": "anything"}, "pos2_smallest": {"name": "pos2_smallest", "group": "Ungrouped variables", "definition": "sort(list(tumbleVector(seed,vec_length,-99999,99999)/1000))[pos2-1]", "description": "

the pos2th smallest value in x1

", "templateType": "anything"}, "smallest_x1": {"name": "smallest_x1", "group": "Ungrouped variables", "definition": "min(list(tumbleVector(seed,vec_length,-99999,99999)/1000))", "description": "", "templateType": "anything"}, "random_value": {"name": "random_value", "group": "Ungrouped variables", "definition": "list(tumbleVector(seed,vec_length,-99999,99999)/1000)[pos-1]", "description": "", "templateType": "anything"}, "lims": {"name": "lims", "group": "Ungrouped variables", "definition": "sort(repeat(random(-4000..4000) / 100, 4))", "description": "

4 limits to be used in range based questions.  These values are sorted into ascending order.

", "templateType": "anything"}, "range1": {"name": "range1", "group": "Ungrouped variables", "definition": "len(filter(x > lims[1] and x < lims[2], x, list(tumbleVector(seed,vec_length,-99999,99999)/1000)))", "description": "

Number of values inside an exclusively-bounded range

", "templateType": "anything"}, "pos": {"name": "pos", "group": "Ungrouped variables", "definition": "random(1000..(vec_length-1000))", "description": "

A randomly selected position in the vector

", "templateType": "anything"}, "pos2": {"name": "pos2", "group": "Ungrouped variables", "definition": "random(400..1000)", "description": "", "templateType": "anything"}, "vec_length": {"name": "vec_length", "group": "Ungrouped variables", "definition": "random(3000 .. 4000#1)", "description": "

The length of the numeric vector that will be created.

", "templateType": "randrange"}, "final_value": {"name": "final_value", "group": "Ungrouped variables", "definition": "list(tumbleVector(seed,vec_length,-99999,99999)/1000)[vec_length-1]", "description": "", "templateType": "anything"}, "range2": {"name": "range2", "group": "Ungrouped variables", "definition": "len(filter(x >= lims[0] and x <= lims[3], x, list(tumbleVector(seed,vec_length,-99999,99999)/1000)))", "description": "

Number of values inside an inclusively-bounded range

", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["vec_length", "pos", "pos2", "lims", "range1", "range2", "smallest_x1", "pos2_smallest", "seed", "random_value", "final_value"], "variable_groups": [], "functions": {"tumblevector": {"parameters": [["a", "number"], ["length", "number"], ["minint", "number"], ["maxint", "number"]], "type": "vector", "language": "javascript", "definition": "var v=Array();\nfor (var i=0;iWhat is the length of the vector v?

", "minValue": "vec_length", "maxValue": "vec_length", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

What is the value of the element in position {pos} of the vector v?

", "minValue": "random_value", "maxValue": "random_value", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

What is the final element in the vector v?

", "minValue": "final_value", "maxValue": "final_value", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

What is the smallest value in the vector v?

", "minValue": "smallest_x1", "maxValue": "smallest_x1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many values in the vector v are greater than {lims[1]} and also less than {lims[2]}?

", "minValue": "range1", "maxValue": "range1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many values in the vector v are in the range $[\\var{lims[0]}, \\var{lims[3]}]$?

\n

(Note: this range includes the values $\\var{lims[0]}$ and $\\var{lims[3]}$)

", "minValue": "range2", "maxValue": "range2", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": "1", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "
\n

What is the {pos2}st smallest number in the vector v?

\n
\n
\n

What is the {pos2}nd smallest number in the vector v?

\n
\n
\n

What is the {pos2}rd smallest number in the vector v?

\n
\n
\n

What is the {pos2}th smallest number in the vector v?

\n
", "minValue": "pos2_smallest", "maxValue": "pos2_smallest", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}]}]}, {"name": "SPSS", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": [""], "questions": [{"name": "Random file in SPSS", "extensions": [], "custom_part_types": [], "resources": [["question-resources/B16.sav", "/srv/numbas/media/question-resources/B16.sav"], ["question-resources/B18.sav", "/srv/numbas/media/question-resources/B18.sav"], ["question-resources/B25.sav", "/srv/numbas/media/question-resources/B25.sav"], ["question-resources/B35.sav", "/srv/numbas/media/question-resources/B35.sav"], ["question-resources/B51.sav", "/srv/numbas/media/question-resources/B51.sav"], ["question-resources/B63.sav", "/srv/numbas/media/question-resources/B63.sav"], ["question-resources/B77.sav", "/srv/numbas/media/question-resources/B77.sav"], ["question-resources/B82.sav", "/srv/numbas/media/question-resources/B82.sav"], ["question-resources/B84.sav", "/srv/numbas/media/question-resources/B84.sav"], ["question-resources/B87.sav", "/srv/numbas/media/question-resources/B87.sav"], ["question-resources/B97.sav", "/srv/numbas/media/question-resources/B97.sav"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/3/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}], "tags": [], "metadata": {"description": "

SPSS fat absorption question. Student downloads one of several SPSS files and carries out some analysis in SPSS, before returning to enter the answers. The analysis is a one-way analysis of variance. If there is a difference in the levels of the factor then a post hoc test (Tukey's honestly significant difference) is used to determine which pairs of variables are significantly different. 

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

An experiment by the Kremey Krisp Donut Company aimed to investigate the amount of fat that is absorbed by its doughnuts. Click the link below to download the data gathered during the experiment.

\n

Experimental data

\n

The variable absorb contains the amount of fat (in grams) absorbed in 24 equally sized batches of doughnuts.

\n

The variable fat contains the corresponding type of fat used for each batch (fat is a factor with four levels labelled 1, 2, 3 and 4).

\n

\n

Carry out a one-way analysis of variance (ANOVA) on these data in SPSS to assess whether the mean amount of fat absorbed depends on the type of fat used.

", "advice": "

One-way analysis of variance was covered in Chapter 3 and Practical 3 of the Quantitative Methods section of ACE2066. Statistical significance is judged at the 5% level throughout. If your p-value is less than 5% then you reject the null hpothesis. 

", "rulesets": {}, "variables": {"scenario": {"name": "scenario", "group": "Ungrouped variables", "definition": "spss[j]", "description": "

The scenario shown to the student.

", "templateType": "anything"}, "j": {"name": "j", "group": "Ungrouped variables", "definition": "random(0..10)", "description": "

Determines which file to use. 

", "templateType": "anything"}, "choicemarks": {"name": "choicemarks", "group": "Ungrouped variables", "definition": "if(scenario[\"sig\"],[1,0],[0,1])", "description": "

marking matrix for the 'choose one from a list' part

", "templateType": "anything"}, "spss": {"name": "spss", "group": "Ungrouped variables", "definition": "json_decode(safe(\"[\\n {\\n \\\"file\\\": \\\"resources/question-resources/B16.sav\\\",\\n \\\"p\\\": 0.01,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 0,\\n \\\"1v3\\\": 1,\\n \\\"1v4\\\": 0,\\n \\\"2v3\\\": 1,\\n \\\"2v4\\\": 0,\\n \\\"3v4\\\": 1\\n },\\n {\\n \\\"file\\\": \\\"resources/question-resources/B18.sav\\\",\\n \\\"p\\\": 0.003,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 0,\\n \\\"1v3\\\": 0,\\n \\\"1v4\\\": 1,\\n \\\"2v3\\\": 0,\\n \\\"2v4\\\": 1,\\n \\\"3v4\\\": 1\\n },\\n {\\n \\\"file\\\": \\\"resources/question-resources/B25.sav\\\",\\n \\\"p\\\": 0.001,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 1,\\n \\\"1v3\\\": 0,\\n \\\"1v4\\\": 0,\\n \\\"2v3\\\": 1,\\n \\\"2v4\\\": 1,\\n \\\"3v4\\\": 0\\n },\\n {\\n \\\"file\\\": \\\"resources/question-resources/B35.sav\\\",\\n \\\"p\\\": 0.044,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 0,\\n \\\"1v3\\\": 0,\\n \\\"1v4\\\": 0,\\n \\\"2v3\\\": 0,\\n \\\"2v4\\\": 0,\\n \\\"3v4\\\": 1\\n },\\n {\\n \\\"file\\\": \\\"resources/question-resources/B51.sav\\\",\\n \\\"p\\\": 0.018,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 0,\\n \\\"1v3\\\": 0,\\n \\\"1v4\\\": 1,\\n \\\"2v3\\\": 0,\\n \\\"2v4\\\": 0,\\n \\\"3v4\\\": 0\\n },\\n {\\n \\\"file\\\": \\\"resources/question-resources/B63.sav\\\",\\n \\\"p\\\": 0.003,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 0,\\n \\\"1v3\\\": 0,\\n \\\"1v4\\\": 1,\\n \\\"2v3\\\": 0,\\n \\\"2v4\\\": 1,\\n \\\"3v4\\\": 0\\n },\\n {\\n \\\"file\\\": \\\"resources/question-resources/B77.sav\\\",\\n \\\"p\\\": 0.049,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 0,\\n \\\"1v3\\\": 0,\\n \\\"1v4\\\": 0,\\n \\\"2v3\\\": 1,\\n \\\"2v4\\\": 0,\\n \\\"3v4\\\": 0\\n },\\n {\\n \\\"file\\\": \\\"resources/question-resources/B82.sav\\\",\\n \\\"p\\\": 0.014,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 1,\\n \\\"1v3\\\": 0,\\n \\\"1v4\\\": 0,\\n \\\"2v3\\\": 0,\\n \\\"2v4\\\": 0,\\n \\\"3v4\\\": 0\\n },\\n {\\n \\\"file\\\": \\\"resources/question-resources/B84.sav\\\",\\n \\\"p\\\": 0.022,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 0,\\n \\\"1v3\\\": 0,\\n \\\"1v4\\\": 1,\\n \\\"2v3\\\": 0,\\n \\\"2v4\\\": 0,\\n \\\"3v4\\\": 1\\n },\\n {\\n \\\"file\\\": \\\"resources/question-resources/B87.sav\\\",\\n \\\"p\\\": 0.006,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 0,\\n \\\"1v3\\\": 1,\\n \\\"1v4\\\": 1,\\n \\\"2v3\\\": 0,\\n \\\"2v4\\\": 0,\\n \\\"3v4\\\": 0\\n },\\n {\\n \\\"file\\\": \\\"resources/question-resources/B97.sav\\\",\\n \\\"p\\\": 0.002,\\n \\\"sig\\\": 1,\\n \\\"1v2\\\": 1,\\n \\\"1v3\\\": 1,\\n \\\"1v4\\\": 1,\\n \\\"2v3\\\": 0,\\n \\\"2v4\\\": 0,\\n \\\"3v4\\\": 0\\n }\\n]\"))", "description": "

A list of scenarios - one will be shown to the student to analyse.

", "templateType": "json"}, "choicemarks2": {"name": "choicemarks2", "group": "Ungrouped variables", "definition": "let(ns,map(scenario[key],key,[\"1v2\",\"1v3\",\"1v4\",\"2v3\",\"2v4\",\"3v4\"]),\n let(n,2/sum(ns),\n map(if(q=0,-n,n),q,ns)+[0]\n )\n)", "description": "

marking matrix for the several from a list part

", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["j", "spss", "scenario", "choicemarks", "choicemarks2"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Enter the p-value for the test of the null hypothesis that there are no differences in the mean amount of fat absorbed for the different types of fat.

\n

[[0]]

", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "2", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "minValue": "spss[j][\"p\"]", "maxValue": "spss[j][\"p\"]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "1_n_2", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Which of the following statements best summarises the conclusions from the  test?

", "minMarks": 0, "maxMarks": "1", "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["

The differences in fat absorption are statistically significant at the 5% level, based on these data.

", "

The differences in fat absorption are not statistically significant at the 5% level, based on these data.

"], "matrix": "choicemarks"}, {"type": "m_n_2", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

If you found that there were significant differences in fat absorption, use SPSS to perform a post-hoc test (Tukey's honestly significant difference) to see where the differences lie.

\n

Select from the list below the pairs of fats that are significantly different. 

", "minMarks": 0, "maxMarks": "2", "shuffleChoices": false, "displayType": "checkbox", "displayColumns": "1", "minAnswers": 0, "maxAnswers": 0, "warningType": "none", "showCellAnswerState": true, "choices": ["

Fat1 and Fat 2

", "

Fat 1 and Fat 3

", "

Fat 1 and Fat 4

", "

Fat 2 and Fat 3

", "

Fat 2 and Fat 4

", "

Fat 3 and Fat 4

", "

None

"], "matrix": "choicemarks2"}]}]}, {"name": "MATLAB", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": [], "questions": []}], "navigation": {"allowregen": true, "reverse": true, "browse": true, "allowsteps": true, "showfrontpage": true, "showresultspage": "oncompletion", "navigatemode": "sequence", "onleave": {"action": "none", "message": ""}, "preventleave": true, "startpassword": ""}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "feedback": {"showactualmark": true, "showtotalmark": true, "showanswerstate": true, "allowrevealanswer": true, "advicethreshold": 0, "intro": "", "reviewshowscore": true, "reviewshowfeedback": true, "reviewshowexpectedanswer": true, "reviewshowadvice": true, "feedbackmessages": []}, "contributors": [{"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}], "extensions": ["json_from_file", "stats"], "custom_part_types": [], "resources": [["question-resources/tv_u1CHb9S.json", "/srv/numbas/media/question-resources/tv_u1CHb9S.json"], ["question-resources/B16.sav", "/srv/numbas/media/question-resources/B16.sav"], ["question-resources/B18.sav", "/srv/numbas/media/question-resources/B18.sav"], ["question-resources/B25.sav", "/srv/numbas/media/question-resources/B25.sav"], ["question-resources/B35.sav", "/srv/numbas/media/question-resources/B35.sav"], ["question-resources/B51.sav", "/srv/numbas/media/question-resources/B51.sav"], ["question-resources/B63.sav", "/srv/numbas/media/question-resources/B63.sav"], ["question-resources/B77.sav", "/srv/numbas/media/question-resources/B77.sav"], ["question-resources/B82.sav", "/srv/numbas/media/question-resources/B82.sav"], ["question-resources/B84.sav", "/srv/numbas/media/question-resources/B84.sav"], ["question-resources/B87.sav", "/srv/numbas/media/question-resources/B87.sav"], ["question-resources/B97.sav", "/srv/numbas/media/question-resources/B97.sav"]]}