# Set seed for repoducibility
set.seed(13)
# Creating the distributions
normal <- rnorm(1000, 0 ,1)
t_2 <- rt(1000,2)
t_5 <- rt(1000,5)
t_15 <- rt(1000,15)
t_30 <- rt(1000,30)
t_120 <- rt(1000,120)
# Plotting
plot(density(normal),
xlim = c(-5,5),
col = "red",
main = "Normal vs t Distributions",
xlab = "Random Variable Value",
lwd = 3)
lines(density(t_2),
col = "orange",
lwd = 3
)
lines(density(t_5),
col = "green",
lwd = 3
)
lines(density(t_15),
col = "blue",
lwd = 3
)
lines(density(t_30),
col = "orchid",
lwd = 3
)
lines(density(t_120),
col = "wheat4",
lwd = 3
)
legend("topright",
legend = c("Normal", "t (df = 2)", "t (df = 5)", "t (df = 15)", "t (df =
30)", "t (df = 120)"),
col = c("red", "orange", "green", "blue", "orchid", "wheat4"),
lwd = 3,
bty = "0")
# Normal Distribution
set.seed(123) # Set seed for reproducibility
mu <- 108
sigma <- 7.2
data_values <- rnorm(n = 1000, mean = mu, sd = sigma)
# Computing the Z-score
z_scores <- (data_values - mu) / sigma
# Plotting both distributions
par(mfrow = c(1,2))
hist(data_values,
main = "Normal Distribution",
xlab = "Observations",
col = "blue")
hist(z_scores,
main = "Z-Score Distribution",
xlab = "Z-Score",
col = "red")
The normal distribution and the z-score distribution have the same
shape. I assume this is because the z-score only standardizes the normal
distribution to have a mean of 0 and standard deviation of 1, it doesn’t
change the ratio of distribution within the data. Therefore, the overall
bell shape should remain unchanged.
The p-value (probability value), is a statistical measurement that is used with hypothesis testing. The p-value tells us the probability of observing data at least as extreme as what was observed, assuming the null hypothesis were true. This article here helped me better understand https://www.simplypsychology.org/p-value.html