There are 3 gray, 2 red, 2 yellow, and 1 blue marbles in a bag. You mix them up and choose one marble without looking. Which color are you most likely to choose?
bag <- c(rep("Gray",3),rep("Red",2),rep("Yellow",2),"Blue")
N <- 1e6 # 1 million trials
simulation <- sample(x = bag,size = N,replace = T)
probabilities <- prop.table(table(simulation))
probabilities
## simulation
## Blue Gray Red Yellow
## 0.125075 0.375323 0.249846 0.249756
Which number is even?
A. \(11 \times 13 \times 15\)
B. \(13 \times 15 \times 17\)
C. \(11 \times 13 \times 17\)
D. \(13 \times 15 \times 18\)
# 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
q2_data <- data.frame(Choice = LETTERS[1:4],
Number = c(11*13*15,13*15*17,11*13*17,13*15*18))
answer <- q2_data %>%
mutate(Even = Number %% 2 == 0) %>%
filter(Even == TRUE) %>%
pull(Choice)
cat("The even number answer choice is:",answer,"\n")
## The even number answer choice is: D
A company that packs and distributes tea claims that their packs of tea weigh 250 grams. Twenty packs of tea were randomly selected and weighed to the nearest gram. The weights were: \([247,250,253,249,258,252,247,251,257,250,255,250,252,254,251,246,255,252,256,247]\). Assuming that the weights are a random sample from a Normal distribution with population mean \(\mu\), carry out a two-tailed test at the 5% level using the following null and alternative hypotheses: \(H_0: \mu = 250\), \(H_1: \mu \neq 250\).
bag_weights <- c(247,250,253,249,258,252,247,251,257,250,255,250,252,254,251,246,255,252,256,247)
t.test(bag_weights,alternative = "two.sided",mu = 250,conf.level = 0.95)
##
## One Sample t-test
##
## data: bag_weights
## t = 2.053, df = 19, p-value = 0.0541
## alternative hypothesis: true mean is not equal to 250
## 95 percent confidence interval:
## 249.9688 253.2312
## sample estimates:
## mean of x
## 251.6
What is \(\int 3e^x - 5x 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(3 * exp(x) - 5 * x ~ x)
anti_f <- antiD(f(x) ~ x)
anti_f
## function (x, C = 0)
## {
## F <- makeF(3 * exp(x) - 5 * x)
## evalFun(F, x = x, .const = C)
## }
## <environment: 0x0000029dcac56118>