#include #include using namespace std; // In a certain plant, the time taken to assemble a car is a random // variable, X, having a normal distribution with a mean of 20 hours // and a standard deviation of 2 hours. What is the probability that a // car can be assembled at this plant in: // 1) Less than 19.5 hours? // 2) Between 20 and 22 hours? int main() { int mean = 20; // mu int stddev = 2; // sigma // Probability P(X <= x) auto normalCDF = [](double x, double mean, double stddev) { double val = (x - mean)/(stddev * sqrt(2)); return 0.5 * (1 + (erf(val))); }; // P(a <= X <= b) = P(a < X < b) = normalCDF(b) - normalCDF(a) double answer_1 = normalCDF(19.5, mean, stddev); double answer_2 = normalCDF(22, mean, stddev) - normalCDF(20, mean, stddev); cout << fixed << setprecision(3) << answer_1 << endl; cout << fixed << setprecision(3) << answer_2 << endl; }