A statistics computation uses \(\int \frac{2}{x(x - 8)} dx\). What is its antiderivative?
# 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(2 / (x * (x - 8)) ~ x)
anti_f <- antiD(f(x) ~ x)
anti_f
## function (x, C = 0)
## (log(8 * (x - 8)) - log(8 * x))/4 + C
Given \(A = \begin{pmatrix} 2 & 1 & 0 \\ 0 & 3 & 2 \\ 1 & 0 & 1 \end{pmatrix}\), find \(A^{-1}\).
# install.packages("matrixcalc")
library(matrixcalc)
## Warning: package 'matrixcalc' was built under R version 4.5.2
A <- matrix(data = c(2,1,0,0,3,2,1,0,1),nrow = 3,ncol = 3,byrow = T)
if (det(A) == 0) {
cat("Matrix A inverse does not exist.")
} else {
matrix.inverse(A)
}
## [,1] [,2] [,3]
## [1,] 0.375 -0.125 0.25
## [2,] 0.250 0.250 -0.50
## [3,] -0.375 0.125 0.75
There are two spinners. The first spinner is in the shape of a regular pentagon, and is marked with the numbers 1 to 5. The second spinner is in the shape of a regular hexagon, and is marked with the numbers 1 to 6. Ursula spins the two spinners at the same time and adds the scores. What is the probability that the sum of scores is eight or more?
spinner1 <- 1:5
spinner2 <- 1:6
N <- 1e6 # 1 million trials
counter <- 0
for (i in 1:N) {
spin1 <- sample(x = spinner1,size = 1,replace = T)
spin2 <- sample(x = spinner2,size = 1,replace = T)
if (spin1 + spin2 >= 8) {
counter <- counter + 1
} else {
next
}
}
probability <- counter / N
cat("The probability that the sum of scores is eight or more is:",probability,"\n")
## The probability that the sum of scores is eight or more is: 0.333189