Question 1

Determine the length of the function \(v(t) = \frac{2}{3} (t - 1)^{\frac{3}{2}}\) on the interval \([1,4]\).

# install.packages("pracma")
library(pracma)
v <- function(t) {
  c((2/3) * (t - 1)^(3 / 2),t) # c(your_function,your_variable) is a parametrized function
}
arc_length <- arclength(f = v,a = 1,b = 4)$length # extracting arclength
cat("The length of the function on the interval [1,4] is:",arc_length,"\n")
## The length of the function on the interval [1,4] is: 4.666666

Question 2

Calculate descriptive statistics for \([87,75,79,87,88,85,89,90,75,79,105]\).

# install.packages("summarytools")
library(summarytools)
nums <- c(87,75,79,87,88,85,89,90,75,79,105)
descr(nums)
## Descriptive Statistics  
## nums  
## N: 11  
## 
##                       nums
## ----------------- --------
##              Mean    85.36
##           Std.Dev     8.54
##               Min    75.00
##                Q1    79.00
##            Median    87.00
##                Q3    89.00
##               Max   105.00
##               MAD     4.45
##               IQR     9.50
##                CV     0.10
##          Skewness     0.73
##       SE.Skewness     0.66
##          Kurtosis     0.01
##           N.Valid    11.00
##                 N    11.00
##         Pct.Valid   100.00

Question 3

Estimate how many of the whole numbers from 1 to 900 are divisible by 7.

# install.packages("comprehenr")
library(comprehenr)
## Warning: package 'comprehenr' was built under R version 4.5.2
nums_by_7 <- to_vec(for (x in 1:900) if (x %% 7 == 0) x)
cat("There are",length(nums_by_7),"whole numbers between 1 and 900 that are divisible by 7.","\n")
## There are 128 whole numbers between 1 and 900 that are divisible by 7.

Question 4

Which number out of \([4347,4364,4428,4490]\) is divisible by 12?

# install.packages("comprehenr")
library(comprehenr)
num_by_12 <- to_vec(for (y in c(4347,4364,4428,4490)) if (y %% 12 == 0) y)
cat("The number",num_by_12,"is divisible by 12.","\n")
## The number 4428 is divisible by 12.

Question 5

A bag contains 3 white balls, 4 green balls, and 5 red balls. Valeria randomly draws two balls without replacement. Use a Monte Carlo simulation to estimate the probability of picking a red ball and a green ball at the same time.

set.seed(123) # for reproducibility
bag <- c(rep("White",3),rep("Green",4),rep("Red",5))
counter <- 0
N <- 100000
for (i in 1:N) {
  pick <- sample(x = bag,size = 2,replace = F)
  if (("Red" %in% pick) & ("Green" %in% pick)) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability of picking a red and green ball at the same time is:",probability,"\n")
## The probability of picking a red and green ball at the same time is: 0.30475