Skip to content

Commit

Permalink
Built site for gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Quarto GHA Workflow Runner committed Sep 16, 2024
1 parent 951745a commit 9f81933
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .nojekyll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8f433c11
a4586231
2 changes: 1 addition & 1 deletion assignments/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"href": "template1.html",
"title": "Notebook for Assignment 1",
"section": "",
"text": "1 General information\nThe exercises here refer to the lecture 1/BDA chapter 1 content, not the course infrastructure quiz. This assignment is meant to test whether or not you have sufficient knowledge to participate in the course. The first question checks that you remember basic terms of probability calculus. The second exercise checks you recognise the most important notation used throughout the course and used in BDA3. The third-fifth exercise you will solve some basic Bayes theorem questions to check your understanding on the basics of probability theory. The 6th exercise checks on whether you recall the three steps of Bayesian Data Ananlysis as mentioned in chapter 1 of BDA3. The last exercise walks you through an example of how we can use models to generate distributions for outcomes of interest, applied to a setting of a simplified Roulette table.\nThis quarto document is not intended to be submitted, but to render the questions as they appear on Mycourses to be available also outside of it. The following will set-up markmyassignment to check your functions at the end of the notebook:\n\nlibrary(markmyassignment)\nassignment_path = paste(\"https://github.com/avehtari/BDA_course_Aalto/\",\n\"blob/master/tests/assignment1.yml\", sep=\"\")\nset_assignment(assignment_path)\n\nAssignment set:\nassignment1: Bayesian Data Analysis: Assignment 1\nThe assignment contain the following (3) tasks:\n- p_red\n- p_box\n- p_identical_twin\n\n\n\n\n2 1. Basic probability theory notation and terms\n\n\n3 2. Notation\n\n\n4 3. Bayes’ theorem 1\nIf you use pen and paper, it may help to draw pictures as follows (see also assignment_instructions#fig-workflow):\n\n\n\n\n\n\nFigure 1: Parts of Bayesian workflow\n\n\n\nSee Figure 1 for illustration of parts of Bayesian workflow.\n\n\n5 4. Bayes’ theorem 2\nThe following will help you implementing a function to calculate the required probabilities for this exercise. Keep the below name and format for the function to work with markmyassignment:\n\nboxes_test <- matrix(c(2,2,1,5,5,1), ncol = 2,\n dimnames = list(c(\"A\", \"B\", \"C\"), c(\"red\", \"white\")))\n\np_red <- function(boxes) {\n # Do computation here, and return as below.\n # This is the correct return value for the test data provided above.\n 0.3928571\n}\n\np_box <- function(boxes) {\n # Do computation here, and return as below.\n # This is the correct return value for the test data provided above.\n c(0.29090909,0.07272727,0.63636364)\n}\n\n\n\n6 5. Bayes’ theorem 3\nThe R functions below might help you calculating the requited probabilities.\n\nfraternal_prob = 1/125\nidentical_prob = 1/300\n\nKeep the below name and format for the function to work with markmyassignment:\n\np_identical_twin <- function(fraternal_prob, identical_prob) {\n # Do computation here, and return as below.\n # This is the correct return value for the test data provided above.\n 0.4545455\n}\n\n\n\n7 6. The three steps of Bayesian data analysis\n\n\n8 7. A Binomial Model for the Roulette Table\nIncomplete code can be found below.\n\n# Ratio of red/black\ntheta <- # declare probability parameter for the binomial model\n\n# Sequence of trials\n\ntrials <- seq(#start value of sequence,#end value of sequence,#value for spacing)\n\n# Number of simulation draws from the model\nnsims <- # number of of simulations from the binomial model\n\n# Helper function for getting the ratios\nbinom_gen <- function(trials,theta,nsims){\n df <- as.data.frame(rbinom(nsims,trials,theta)/trials) |> mutate(nsims = nsims,trials = trials)\n colnames(df) <- c(\"Ratios\",\"Nsims\",\"Trials\")\n return(df)\n}\n\n# Create a data frame containing the draws for each number of trials\nratio_60 <- do.call(rbind, lapply(trials, binom_gen, theta, nsims)) # lapply applies elements in trials column to binom_gen function, which is then rowbound via do.call\n\nNow plot a histogram of the computed ratios for 10, 50 and 1000 trials, using the code below\n\n# Plot the Distributions\nsubset_df60 <- ratio_60[ratio_60$Trials %in% c(#trial values), ] # Subset your dataframe\n\nsubset_df60 |> ggplot(aes(Ratios)) +\n geom_histogram(position = \"identity\" ,bins = 40) +\n facet_grid(cols = vars(Trials)) +\n ggtitle(\"Ratios for specific trials\")\n\nSuppose you are now certain that theta = 0.6, plot the probability density given 1000 trials using the code below.\n\nsize = # number of trials\nprob = # probability of success\n\nbinom_data <- data.frame(\n Success = 0:size,\n Probability = dbinom(0:size, size = size, prob = prob)\n)\n\nggplot(binom_data, aes(x = Success, y = Probability)) +\n geom_point() +\n geom_line() +\n labs(title = \"PMF of Binomial Distribution\", x = \"Number of Successes\", y = \"PDF\")\n\n\n\n\n\n\n\nmarkmyassignment\n\n\n\n\n\nThe following will check the functions for which markmyassignment has been set up:\n\nmark_my_assignment()\n\n✔ | F W S OK | Context\n\n⠏ | 0 | task-1-subtask-1-tests \n⠏ | 0 | p_red() \n✖ | 1 3 | p_red()\n────────────────────────────────────────────────────────────────────────────────\nFailure ('test-task-1-subtask-1-tests.R:21:3'): p_red()\np_red(boxes = boxes) not equivalent to 0.5.\n1/1 mismatches\n[1] 0.393 - 0.5 == -0.107\nError: Incorrect result for matrix(c(1,1,1,1,1,1), ncol = 2)\n────────────────────────────────────────────────────────────────────────────────\n\n⠏ | 0 | task-2-subtask-1-tests \n⠏ | 0 | p_box() \n✖ | 1 3 | p_box()\n────────────────────────────────────────────────────────────────────────────────\nFailure ('test-task-2-subtask-1-tests.R:19:3'): p_box()\np_box(boxes = boxes) not equivalent to c(0.4, 0.1, 0.5).\n3/3 mismatches (average diff: 0.0909)\n[1] 0.2909 - 0.4 == -0.1091\n[2] 0.0727 - 0.1 == -0.0273\n[3] 0.6364 - 0.5 == 0.1364\nError: Incorrect result for matrix(c(1,1,1,1,1,1), ncol = 2)\n────────────────────────────────────────────────────────────────────────────────\n\n⠏ | 0 | task-3-subtask-1-tests \n⠏ | 0 | p_identical_twin() \n✖ | 2 3 | p_identical_twin()\n────────────────────────────────────────────────────────────────────────────────\nFailure ('test-task-3-subtask-1-tests.R:16:3'): p_identical_twin()\np_identical_twin(fraternal_prob = 1/100, identical_prob = 1/500) not equivalent to 0.2857143.\n1/1 mismatches\n[1] 0.455 - 0.286 == 0.169\nError: Incorrect result for fraternal_prob = 1/100 and identical_prob = 1/500\n\nFailure ('test-task-3-subtask-1-tests.R:19:3'): p_identical_twin()\np_identical_twin(fraternal_prob = 1/10, identical_prob = 1/20) not equivalent to 0.5.\n1/1 mismatches\n[1] 0.455 - 0.5 == -0.0455\nError: Incorrect result for fraternal_prob = 1/10 and identical_prob = 1/20\n────────────────────────────────────────────────────────────────────────────────\n\n══ Results ═════════════════════════════════════════════════════════════════════\n── Failed tests ────────────────────────────────────────────────────────────────\nFailure ('test-task-1-subtask-1-tests.R:21:3'): p_red()\np_red(boxes = boxes) not equivalent to 0.5.\n1/1 mismatches\n[1] 0.393 - 0.5 == -0.107\nError: Incorrect result for matrix(c(1,1,1,1,1,1), ncol = 2)\n\nFailure ('test-task-2-subtask-1-tests.R:19:3'): p_box()\np_box(boxes = boxes) not equivalent to c(0.4, 0.1, 0.5).\n3/3 mismatches (average diff: 0.0909)\n[1] 0.2909 - 0.4 == -0.1091\n[2] 0.0727 - 0.1 == -0.0273\n[3] 0.6364 - 0.5 == 0.1364\nError: Incorrect result for matrix(c(1,1,1,1,1,1), ncol = 2)\n\nFailure ('test-task-3-subtask-1-tests.R:16:3'): p_identical_twin()\np_identical_twin(fraternal_prob = 1/100, identical_prob = 1/500) not equivalent to 0.2857143.\n1/1 mismatches\n[1] 0.455 - 0.286 == 0.169\nError: Incorrect result for fraternal_prob = 1/100 and identical_prob = 1/500\n\nFailure ('test-task-3-subtask-1-tests.R:19:3'): p_identical_twin()\np_identical_twin(fraternal_prob = 1/10, identical_prob = 1/20) not equivalent to 0.5.\n1/1 mismatches\n[1] 0.455 - 0.5 == -0.0455\nError: Incorrect result for fraternal_prob = 1/10 and identical_prob = 1/20\n\n[ FAIL 4 | WARN 0 | SKIP 0 | PASS 9 ]\n\nNo one gets it right on their first try",
"text": "1 General information\nThe exercises here refer to the lecture 1/BDA chapter 1 content, not the course infrastructure quiz. This assignment is meant to test whether or not you have sufficient knowledge to participate in the course. The first question checks that you remember basic terms of probability calculus. The second exercise checks you recognise the most important notation used throughout the course and used in BDA3. The third-fifth exercise you will solve some basic Bayes theorem questions to check your understanding on the basics of probability theory. The 6th exercise checks on whether you recall the three steps of Bayesian Data Ananlysis as mentioned in chapter 1 of BDA3. The last exercise walks you through an example of how we can use models to generate distributions for outcomes of interest, applied to a setting of a simplified Roulette table.\nThis quarto document is not intended to be submitted, but to render the questions as they appear on Mycourses to be available also outside of it. The following will set-up markmyassignment to check your functions at the end of the notebook:\n\nlibrary(markmyassignment)\nassignment_path = paste(\"https://github.com/avehtari/BDA_course_Aalto/\",\n\"blob/master/tests/assignment1.yml\", sep=\"\")\nset_assignment(assignment_path)\n\nAssignment set:\nassignment1: Bayesian Data Analysis: Assignment 1\nThe assignment contain the following (3) tasks:\n- p_red\n- p_box\n- p_identical_twin\n\n\n\n\n2 1. Basic probability theory notation and terms\n\n\n3 2. Notation\n\n\n4 3. Bayes’ theorem 1\nIf you use pen and paper, it may help to draw pictures as follows (see also assignment_instructions#fig-workflow):\n\n\n\n\n\n\nFigure 1: Parts of Bayesian workflow\n\n\n\nSee Figure 1 for illustration of parts of Bayesian workflow.\n\n\n5 4. Bayes’ theorem 2\nThe following will help you implementing a function to calculate the required probabilities for this exercise. Keep the below name and format for the function to work with markmyassignment:\n\nboxes_test <- matrix(c(2,2,1,5,5,1), ncol = 2,\n dimnames = list(c(\"A\", \"B\", \"C\"), c(\"red\", \"white\")))\n\np_red <- function(boxes) {\n # Do computation here, and return as below.\n # This is the correct return value for the test data provided above.\n 0.3928571\n}\n\np_box <- function(boxes) {\n # Do computation here, and return as below.\n # This is the correct return value for the test data provided above.\n c(0.29090909,0.07272727,0.63636364)\n}\n\n\n\n6 5. Bayes’ theorem 3\nThe R functions below might help you calculating the requited probabilities.\n\nfraternal_prob = 1/125\nidentical_prob = 1/300\n\nKeep the below name and format for the function to work with markmyassignment:\n\np_identical_twin <- function(fraternal_prob, identical_prob) {\n # Do computation here, and return as below.\n # This is the correct return value for the test data provided above.\n 0.4545455\n}\n\n\n\n7 6. The three steps of Bayesian data analysis\n\n\n8 7. A Binomial Model for the Roulette Table\nIncomplete code can be found below.\n\n# Ratio of red/black\ntheta <- # declare probability parameter for the binomial model\n\n# Sequence of trials\n\ntrials <- seq(#start value of sequence,#end value of sequence,#value for spacing)\n\n# Number of simulation draws from the model\nnsims <- # number of of simulations from the binomial model\n\n# Helper function for getting the ratios\nbinom_gen <- function(trials,theta,nsims){\n df <- as.data.frame(rbinom(nsims,trials,theta)/trials) |> mutate(nsims = nsims,trials = trials)\n colnames(df) <- c(\"Ratios\",\"Nsims\",\"Trials\")\n return(df)\n}\n\n# Create a data frame containing the draws for each number of trials\nratio_60 <- do.call(rbind, lapply(trials, binom_gen, theta, nsims)) # lapply applies elements in trials column to binom_gen function, which is then rowbound via do.call\n\nNow plot a histogram of the computed ratios for 10, 50 and 1000 trials, using the code below\n\n# Plot the Distributions\nsubset_df60 <- ratio_60[ratio_60$Trials %in% c(#trial values), ] # Subset your dataframe\n\nsubset_df60 |> ggplot(aes(Ratios)) +\n geom_histogram(position = \"identity\" ,bins = 40) +\n facet_grid(cols = vars(Trials)) +\n ggtitle(\"Ratios for specific trials\")\n\nSuppose you are now certain that theta = 0.6, plot the probability density given 1000 trials using the code below.\n\nsize = # number of trials\nprob = # probability of success\n\nbinom_data <- data.frame(\n Success = 0:size,\n Probability = dbinom(0:size, size = size, prob = prob)\n)\n\nggplot(binom_data, aes(x = Success, y = Probability)) +\n geom_point() +\n geom_line() +\n labs(title = \"PMF of Binomial Distribution\", x = \"Number of Successes\", y = \"PDF\")\n\n\n\n\n\n\n\nmarkmyassignment\n\n\n\n\n\nThe following will check the functions for which markmyassignment has been set up:\n\nmark_my_assignment()\n\n✔ | F W S OK | Context\n\n⠏ | 0 | task-1-subtask-1-tests \n⠏ | 0 | p_red() \n✖ | 1 3 | p_red()\n────────────────────────────────────────────────────────────────────────────────\nFailure ('test-task-1-subtask-1-tests.R:21:3'): p_red()\np_red(boxes = boxes) not equivalent to 0.5.\n1/1 mismatches\n[1] 0.393 - 0.5 == -0.107\nError: Incorrect result for matrix(c(1,1,1,1,1,1), ncol = 2)\n────────────────────────────────────────────────────────────────────────────────\n\n⠏ | 0 | task-2-subtask-1-tests \n⠏ | 0 | p_box() \n✖ | 1 3 | p_box()\n────────────────────────────────────────────────────────────────────────────────\nFailure ('test-task-2-subtask-1-tests.R:19:3'): p_box()\np_box(boxes = boxes) not equivalent to c(0.4, 0.1, 0.5).\n3/3 mismatches (average diff: 0.0909)\n[1] 0.2909 - 0.4 == -0.1091\n[2] 0.0727 - 0.1 == -0.0273\n[3] 0.6364 - 0.5 == 0.1364\nError: Incorrect result for matrix(c(1,1,1,1,1,1), ncol = 2)\n────────────────────────────────────────────────────────────────────────────────\n\n⠏ | 0 | task-3-subtask-1-tests \n⠏ | 0 | p_identical_twin() \n✖ | 2 3 | p_identical_twin()\n────────────────────────────────────────────────────────────────────────────────\nFailure ('test-task-3-subtask-1-tests.R:16:3'): p_identical_twin()\np_identical_twin(fraternal_prob = 1/100, identical_prob = 1/500) not equivalent to 0.2857143.\n1/1 mismatches\n[1] 0.455 - 0.286 == 0.169\nError: Incorrect result for fraternal_prob = 1/100 and identical_prob = 1/500\n\nFailure ('test-task-3-subtask-1-tests.R:19:3'): p_identical_twin()\np_identical_twin(fraternal_prob = 1/10, identical_prob = 1/20) not equivalent to 0.5.\n1/1 mismatches\n[1] 0.455 - 0.5 == -0.0455\nError: Incorrect result for fraternal_prob = 1/10 and identical_prob = 1/20\n────────────────────────────────────────────────────────────────────────────────\n\n══ Results ═════════════════════════════════════════════════════════════════════\n── Failed tests ────────────────────────────────────────────────────────────────\nFailure ('test-task-1-subtask-1-tests.R:21:3'): p_red()\np_red(boxes = boxes) not equivalent to 0.5.\n1/1 mismatches\n[1] 0.393 - 0.5 == -0.107\nError: Incorrect result for matrix(c(1,1,1,1,1,1), ncol = 2)\n\nFailure ('test-task-2-subtask-1-tests.R:19:3'): p_box()\np_box(boxes = boxes) not equivalent to c(0.4, 0.1, 0.5).\n3/3 mismatches (average diff: 0.0909)\n[1] 0.2909 - 0.4 == -0.1091\n[2] 0.0727 - 0.1 == -0.0273\n[3] 0.6364 - 0.5 == 0.1364\nError: Incorrect result for matrix(c(1,1,1,1,1,1), ncol = 2)\n\nFailure ('test-task-3-subtask-1-tests.R:16:3'): p_identical_twin()\np_identical_twin(fraternal_prob = 1/100, identical_prob = 1/500) not equivalent to 0.2857143.\n1/1 mismatches\n[1] 0.455 - 0.286 == 0.169\nError: Incorrect result for fraternal_prob = 1/100 and identical_prob = 1/500\n\nFailure ('test-task-3-subtask-1-tests.R:19:3'): p_identical_twin()\np_identical_twin(fraternal_prob = 1/10, identical_prob = 1/20) not equivalent to 0.5.\n1/1 mismatches\n[1] 0.455 - 0.5 == -0.0455\nError: Incorrect result for fraternal_prob = 1/10 and identical_prob = 1/20\n\n[ FAIL 4 | WARN 0 | SKIP 0 | PASS 9 ]",
"crumbs": [
"Templates",
"Notebook for Assignment 1"
Expand Down
4 changes: 1 addition & 3 deletions assignments/template1.html
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,7 @@ <h1 data-number="8"><span class="header-section-number">8</span> 7. A Binomial M
[1] 0.455 - 0.5 == -0.0455
Error: Incorrect result for fraternal_prob = 1/10 and identical_prob = 1/20

[ FAIL 4 | WARN 0 | SKIP 0 | PASS 9 ]

No one gets it right on their first try</code></pre>
[ FAIL 4 | WARN 0 | SKIP 0 | PASS 9 ]</code></pre>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 9f81933

Please sign in to comment.