This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.
uniform_sample <- runif(500, min = 0, max = 10)
summary(uniform_sample)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.008216 2.429342 4.562907 4.807240 7.319606 9.966002
hist(uniform_sample, main = "Uniform Distribution (0, 10)", xlab = "Values", col = "lightblue")
p_uniform <- punif(4, min = 0, max = 10)
print(p_uniform)
## [1] 0.4
exponential_sample <- rexp(500, rate = 0.1)
summary(exponential_sample)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.01092 3.11918 6.83579 9.89172 13.29900 58.68270
hist(exponential_sample, main = "Exponential Distribution (rate = 0.1)", xlab = "Values", col = "lightyellow")
p_exponential <- 1 - pexp(7, rate = 0.1)
print(p_exponential)
## [1] 0.4965853
poisson_sample <- rpois(500, lambda = 3)
summary(poisson_sample)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 2.000 3.000 2.922 4.000 9.000
hist(poisson_sample, main = "Poisson Distribution (lambda = 3)", xlab = "Values", col = "lightpink")
p_poisson <- dpois(4, lambda = 3)
print(p_poisson)
## [1] 0.1680314
binomial_sample <- rbinom(500, size = 10, prob = 0.5)
summary(binomial_sample)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.000 4.000 5.000 4.976 6.000 10.000
hist(binomial_sample, main = "Binomial Distribution (n = 10, p = 0.5)", xlab = "Values", col = "lightgreen")
p_binomial <- dbinom(3, size = 10, prob = 0.5)
print(p_binomial)
## [1] 0.1171875