Question 1

Nicola throws two dice at the same time. Then, she adds together the numbers on the top faces of both dice. When Nicola adds the two numbers, which total is more likely?

A. 6

B. 7

C. 8

D. 12

# install.packages("tidyverse")
library(tidyverse)
## Warning: package 'lubridate' was built under R version 4.5.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.1     ✔ stringr   1.5.2
## ✔ ggplot2   4.0.0     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
die1 <- 1:6
die2 <- 1:6
N <- 1e5
counterA <- 0
counterB <- 0
counterC <- 0
counterD <- 0
for (i in 1:N) {
  pick1 <- sample(x = die1,size = 1,replace = T)
  pick2 <- sample(x = die2,size = 1,replace = T)
  if (pick1 + pick2 == 6) {
    counterA <- counterA + 1
  } else if (pick1 + pick2 == 7) {
    counterB <- counterB + 1
  } else if (pick1 + pick2 == 8) {
    counterC <- counterC + 1
  } else if (pick1 + pick2 == 12) {
    counterD <- counterD + 1
  } else {
    next
  }
}
probabilityA <- counterA / N
probabilityB <- counterB / N
probabilityC <- counterC / N
probabilityD <- counterD / N
q1_data <- data.frame(Choice = LETTERS[1:4],Values = c(6,7,8,12),Probabilities = c(probabilityA,probabilityB,probabilityC,probabilityD))
correct_answer <- q1_data %>%
  filter(Probabilities == min(Probabilities)) %>%
  pull(Choice)
correct_value <- q1_data %>%
  filter(Probabilities == min(Probabilities)) %>%
  pull(Values)
cat("The correct answer is",correct_answer,"with a value of",correct_value,"\n")
## The correct answer is D with a value of 12

Question 2

Put \([2678,7682,6872,6287,8276,2867]\) in descending order.

# install.packages("tidyverse")
library(tidyverse)
q2_data <- data.frame(Numbers = c(2678,7682,6872,6287,8276,2867))
q2_data %>%
  arrange(desc(Numbers))
##   Numbers
## 1    8276
## 2    7682
## 3    6872
## 4    6287
## 5    2867
## 6    2678

Question 3

Given the following \((x,y)\) data, plot the polygon.

# install.packages("tidyverse")
library(tidyverse)
q3_data <- data.frame(X = c(3,1,1,6,6,3,3,5,5,3),
                      Y = c(-3,-3,7,7,5,5,3,3,1,1))
ggplot(q3_data,aes(x = X,y = Y)) +
  geom_polygon(fill = "steelblue",color = "black",lwd = 1.25) +
  geom_point(size = 4) +
  theme_gray()

Question 4

Find the cube root of -121 correct to 2 decimal places.

# install.packages("pracma")
library(pracma)
## 
## Attaching package: 'pracma'
## The following object is masked from 'package:purrr':
## 
##     cross
value <- nthroot(x = -121,n = 3) # x = -121 (value),n = 3 (cube root)
cat("The cube root of -121 correct to 2 decimal places is:",round(value,2),"\n")
## The cube root of -121 correct to 2 decimal places is: -4.95

Question 5

What is \(\int x \ln(x) dx\)?

# install.packages(c("ggformula","mosaicCalc"))
library(ggformula)
## Warning: package 'ggformula' was built under R version 4.5.2
## Loading required package: scales
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
## Loading required package: ggiraph
## Warning: package 'ggiraph' was built under R version 4.5.2
## Loading required package: ggridges
## Warning: package 'ggridges' was built under R version 4.5.2
## 
## New to ggformula?  Try the tutorials: 
##  learnr::run_tutorial("introduction", package = "ggformula")
##  learnr::run_tutorial("refining", package = "ggformula")
library(mosaicCalc)
## Warning: package 'mosaicCalc' was built under R version 4.5.2
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D
f <- makeFun(x * log(x) ~ x)
anti_f <- antiD(f(x) ~ x)
anti_f
## function (x, C = 0) 
## (2 * log(x) * x^2 - x^2)/4 + C