mean = 3
std = 0.4
# Simulate 1,000,000 values from the normal distribution
set.seed(123)
simulated_values = rnorm(1000000, mean = mean, sd = std)
# a.What is the simulated mean?
simulated_mean = mean(simulated_values)
simulated_mean
## [1] 2.999791
# b.What is the simulated probability that the result is less than 2?
# Calculate the simulated probability that the result is less than 2
prob_lt_2 = mean(simulated_values < 2)
prob_lt_2
## [1] 0.006283
# c.What is the simulated probability that the result is less than 2, given that it is less than 2.5?
prob_lt_2_lt_2_5 = mean(simulated_values < 2 & simulated_values < 2.5) / mean(simulated_values < 2.5)
prob_lt_2_lt_2_5
## [1] 0.05954152
# d.What is the mean value, given that the result is less than 2.5?
mean_lt_2_5 = mean(simulated_values[simulated_values < 2.5])
mean_lt_2_5
## [1] 2.308008
# Parameters for the normal distribution
mean = 10.0
std = 2.5
# a.What is the probability that a wafer is defective?
prob_a = 1 - pnorm(16.7, mean = mean, sd = std)
cat("Probability that a wafer is defective:", prob_a, "\n")
## Probability that a wafer is defective: 0.003681108
# b.What is the probability that the quality control system will detect a defect in any wafer?
prob_b = 1 - pnorm(17.0, mean = mean, sd = std)
cat("Probability that the quality control system detects a defect:", prob_b, "\n")
## Probability that the quality control system detects a defect: 0.00255513
# c.What is the probability that a wafer is defective, and the quality control system does not detect the defect?
prob_c = pnorm(17.0, mean = mean, sd = std) - pnorm(16.7, mean = mean, sd = std)
cat("Probability that a wafer is defective but not detected:", prob_c, "\n")
## Probability that a wafer is defective but not detected: 0.001125978
set.seed(123)
# a.Binomial, n = 24, p = 0.3
n = 24
p = 0.3
# Simulate 1,000,000 values
binom_values = rbinom(1000000, n, p)
binom_mean = mean(binom_values)
binom_variance = var(binom_values)
# Print results
cat("Binomial Distribution:\n")
## Binomial Distribution:
cat("Mean:", binom_mean, "\n")
## Mean: 7.196494
cat("Variance:", binom_variance, "\n")
## Variance: 5.044367
# b.Exponential distribution, rate = 0.3
lambda = 0.3
# Simulate 1,000,000 values
exp_values = rexp(1000000, lambda)
exp_mean = mean(exp_values)
exp_variance = var(exp_values)
# Print results
cat("\nExponential Distribution:\n")
##
## Exponential Distribution:
cat("Mean:", exp_mean, "\n")
## Mean: 3.330013
cat("Variance:", exp_variance, "\n")
## Variance: 11.08472
# c. Normal distribution, mean = 4, standard deviation = 1.4
mean_norm = 4 # Mean of the distribution
std_norm = 1.4 # Standard deviation
# Simulate 1,000,000 values
norm_values = rnorm(1000000, mean_norm, std_norm)
# Calculate expected value (mean) and variance
norm_mean = mean(norm_values)
norm_variance = var(norm_values)
# Print results
cat("\nNormal Distribution:\n")
##
## Normal Distribution:
cat("Mean:", norm_mean, "\n")
## Mean: 3.999362
cat("Variance:", norm_variance, "\n")
## Variance: 1.961444