Question 1

Your friend asks yo to choose one card from the seven cards below. Which of the suits (diamonds, spades, clubs, hearts) are you least likely to choose? Use a Monte Carlo simulation to solve this problem.

set.seed(123) # for reproducibility
seven_cards <- c("8 Hearts","4 Spades","2 Clubs","2 Hearts","4 Diamonds","6 Clubs","7 Spades")
suits <- sapply(strsplit(seven_cards," "),`[`,2) # extracting suits only
simulation <- sample(x = suits,size = 1e6,replace = T) # 1e6: 1 million trials
probabilities <- prop.table(table(simulation))
probabilities
## simulation
##    Clubs Diamonds   Hearts   Spades 
## 0.285324 0.143154 0.285954 0.285568

We find that Diamonds are the least likely suit to be picked.

Question 2

What is the cube root of 1331?

# install.packages("pracma")
library(pracma)
value <- nthroot(x = 1331,n = 3) # x = 1331 (value), n = 3 (cube root)
cat("The cube root of 1331 is:",value,"\n")
## The cube root of 1331 is: 11

Question 3

What is the following indefinite integral equal to?

\[\int \frac{3x^3 + 2x}{x} dx\]

# install.packages(c("ggformula","mosaicCalc"))
library(ggformula)
## Warning: package 'ggformula' was built under R version 4.5.2
## Loading required package: ggplot2
## Loading required package: scales
## 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((3 * x^3 + 2 * x) / x ~ x)
anti_f <- antiD(f(x) ~ x)
anti_f
## function (x, C = 0) 
## x^3 + 2 * x + C