coin3 <- data.frame(
N_Heads = c(0, 1, 2, 3),
C_Heads = c(1, 3, 3, 1)
)
attach(coin3)
coin3$P_Heads <- C_Heads/sum(C_Heads)
options(repr.plot.width=7, repr.plot.height=4)
barplot(coin3$P_Heads, names = coin3$N_Heads, main = "Discrete Probability Distribution of Flipping Three Coins")
barplot(prop.table(table(c('HHH', 'HHT', 'HHT', 'HTT', 'HHT', 'HTT', 'HTT', 'TTT'))),
main = "Discrete Probability Distribution of Tossing Three Coins",
xlab = "x = Number of Heads", ylab = "P(x)", col = "#6633FF")
attach(coin3)
E_X = sum(N_Heads * P_Heads)
E_X
Uniform_Random_Number <-runif(10000, -2, 1)
hist(Uniform_Random_Number, probability = TRUE)
# Demonstration of Normal Distribution plotting
options(repr.plot.width=7, repr.plot.height=4)
x=seq(-4,4,length=200)
y=1/sqrt(2*pi)*exp(-x^2/2)
plot(x,y,type="l",lwd=2,col="red", main = "Normal Distribution")