Consider a spinner with spots (Red, Orange, Green, Orange, Blue). If you spin the spinner, on which color is it most likely to land?
Spinner <- c("Red","Orange","Green","Orange","Blue")
N <- 1e5 # 100,000 trials
Simulation <- sample(x = Spinner,size = N,replace = T)
probabilities <- prop.table(table(Simulation))
probabilities
## Simulation
## Blue Green Orange Red
## 0.19987 0.19927 0.40149 0.19937
What is \(\int x^5 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(x^5 ~ x)
anti_f <- antiD(f(x) ~ x)
anti_f
## function (x, C = 0)
## x^6/6 + C
Ten volunteers took part in a trial of a food that the manufacturer claimed would help people to lose weight. At the end of the trial, nine of them had lost \([7,1,2,1,0.5,1,0.5,0,1.5]\) kg respectively and one of them gained 1 kg. Assuming that the weight losses are a random sample from a Normal distribution with population mean \(\mu\), carry out a one-tailed t-test at the 5% level using the following null and alternative hypotheses: \(H_0: \mu = 0\), \(H_1: \mu < 0\).
weight_losses_gains <- c(-7,-1,-2,-1,-0.5,-1,-0.5,0,-1.5,1) # positive: weight gain, negative (-): weight loss
t.test(weight_losses_gains,conf.level = 0.95,alternative = "less",mu = 0)
##
## One Sample t-test
##
## data: weight_losses_gains
## t = -1.9875, df = 9, p-value = 0.03906
## alternative hypothesis: true mean is less than 0
## 95 percent confidence interval:
## -Inf -0.1048468
## sample estimates:
## mean of x
## -1.35