Email          : sausan.ramadhani@student.matanauniversity.ac.id
RPubs         : https://rpubs.com/sausanramadhani/
Jurusan    Â
 : Statistika
Address     : ARA Center, Matana University Tower
   Â
         Jl. CBD Barat Kav, RT.1, Curug Sangereng, Kelapa Dua,
Tangerang, Banten 15810.
Suppose there are twenty multiple choice questions in an Statistics
class quiz. Each question has five possible answers, and only one of
them is correct. Find the probability of having four or less correct
answers if a student attempts to answer every question at random.
Diketahui:
20 PG
5 pilihan : 1 benar, 4 salah
Ditanya
:
probability <=4benar (ambil acak)
Jawab :
nS=5 #total pilihan
nA=1 #total pilihan yang benar
#mencari probabilitas pilihan
PA=nA/nS
PA## [1] 0.2
Didapatkan probabilitas dari pilihan sebesar 0.2
Dengan demikian,
kita bisa mencari probabilitas terambilnya kurang dari sama dengan 4
jawaban benar.
dbinom(0, size = 20, prob = 0.2) +
dbinom(1, size = 20, prob = 0.2) +
dbinom(2, size = 20, prob = 0.2) +
dbinom(3, size = 20, prob = 0.2) +
dbinom(4, size = 20, prob = 0.2)## [1] 0.6296483
So, the probability of having four or less correct answers if a
student attempts to answer every question at random is 0.6296483.
Jika ingin mengetahui visualisasinya, maka saya tampilkan di bawah
ini :
library(dplyr)##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
data.frame(heads = 0:20,
pmf = dbinom(x = 0:20, size = 20, prob = 0.2),
cdf = pbinom(q = 0:20, size = 20, prob = 0.2,
lower.tail = TRUE)) %>%
mutate(Heads = ifelse(heads <= 4, "<=4", "lainnya")) %>%
ggplot(aes(x = factor(heads), y = cdf, fill = Heads)) +
geom_col() +
theme_minimal()+
geom_text(
aes(label = round(cdf,2), y = cdf + 0.01),
position = position_dodge(0.9),
size = 3,
vjust = 0) +
labs(title = "Probabilitas X <= 4 Benar",
subtitle = "b(20, .2)",
x = "Benar (x)",
y = "Probabilitas") If twenty cars are crossing a bridge per minute on average, visualize
and find the probability of having thirteen or more cars crossing the
bridge in a particular minute.
Diketahui :
20 mobil - per
menit
Ditanya :
probability >= 13 mobil
Jawab :
library(ggplot2)
library(dplyr)
ppois(q=13,lambda=20,lower.tail=FALSE) # probability of x > 150## [1] 0.9338724
So, the probability of having thirteen or more cars crossing the
bridge in a particular minute is 0.9338724 or 93%.
The visualization
:
options(scipen = 999, digits = 2) # sig digits
hits <- 0:13
density <- dpois(x = hits, lambda = 20)
prob <- ppois(q = hits, lambda = 20, lower.tail = TRUE)
df <- data.frame(hits, density, prob)
ggplot(df, aes(x = hits, y = density)) +
geom_col() +
theme_minimal()+
labs(title = "Poisson(13)",
subtitle = "PMF and CDF of Poisson(3) distribution.",
x = "Hits (x)",
y = "Density") +
geom_line(data = df, aes(x = hits, y = prob))Suppose the probability that a drug produces a certain side effect is
p = = 0.1% and n = 1,000 patients in a clinical trial receive the drug.
What is the probability 0 people experience the side effect by using
visualization techniques?
Diketahui :
p==0.1%
n=1000
Ditanya :
probabilitas 0 orang, dengan teknik visualisasi Jawab
:
library(ggplot2)
library(dplyr)
dpois(x=0,lambda=.001*1000)## [1] 0.37
So, the probability 0 people experience the side effect is 37%.
The probability 0 people experience the side effect by using
visualization techniques :
options(scipen = 999, digits = 2) # sig digits
events <- 0:10
density <- dpois(x = events, lambda = .001*1000)
prob <- ppois(q = events, lambda = .001*1000, lower.tail = TRUE)
df <- data.frame(events, density, prob)
ggplot(df, aes(x = factor(events), y = density)) +
theme_minimal()+
geom_col() +
geom_text(
aes(label = round(density,2), y = density + 0.01),
position = position_dodge(0.9),
size = 3,
vjust = 0) +
labs(title = "PMF and CDF of Poisson Distribution",
subtitle = "P(.001*1000).",
x = "Events (x)",
y = "Density") +
geom_line(data = df, aes(x = events, y = prob))Suppose the mean checkout time of a supermarket cashier is three
minutes. Find the probability of a customer checkout being completed by
the cashier in less than two minutes.
Diketahui :
reratanya 3 menit
Ditanya :
Probabilitas < 2 menit
Jawab :
pexp(2, rate=1/3)## [1] 0.49
So, the probability of a customer checkout being completed by the cashier in less than two minutes is 0.49 or 49%.