Need to find probability

15 visualizaciones (últimos 30 días)
Stirling Ellis
Stirling Ellis el 27 de Abr. de 2022
Comentada: Stirling Ellis el 27 de Abr. de 2022
Hello, my goal is to find the probability a piece of wood has a module of elasticity greater than 2.00e6. My code is below
%Equation and initialized variables
mean = 1930000;
standardDeviation= 64000;
fx = @(x) (1/(standardDeviation * sqrt(2 * pi))) * exp(-((x - mean).^2 / (2 * standardDeviation ^ 2)));
xmin = mean - 3*standardDeviation;
xmax = mean + 3*standardDeviation;
plot(xmin:xmax,fx(xmin:xmax),'o--b')
%Value of Normal PDF
y = pdf('Normal',xmin:xmax,mean,standardDeviation);
This code manages to yield a normal distribution plot. My goal is to try and find what percentage of these values in the plot are above the elasticty of 2.00e6. Thank you so much in advance!

Respuesta aceptada

Image Analyst
Image Analyst el 27 de Abr. de 2022
Editada: Image Analyst el 27 de Abr. de 2022
Try this:
% Equation and initialized variables
mean = 1930000;
standardDeviation= 64000;
fx = @(x) (1/(standardDeviation * sqrt(2 * pi))) * exp(-((x - mean).^2 / (2 * standardDeviation ^ 2)));
xmin = mean - 3*standardDeviation;
xmax = mean + 3*standardDeviation;
x = xmin:xmax;
subplot(2, 1, 1);
plot(x,fx(x),'b-', 'LineWidth', 3);
grid on;
xline(2e6, 'Color', 'r', 'LineWidth', 2);
%Value of Normal PDF
y = pdf('Normal',xmin:xmax,mean,standardDeviation);
cdf = cumsum(y);
% Normalize to 0-100%
cdf = 100 * cdf / cdf(end);
subplot(2, 1, 2);
plot(x, cdf, 'b-', 'LineWidth', 2);
xline(2e6, 'Color', 'r', 'LineWidth', 2);
yticks(0:10:100)
grid on;
% Find value where value is 2e6
index = find(x >= 2e6, 1, 'first')
prob = cdf(index)
yline(prob, 'Color', 'r', 'LineWidth', 2)
message = sprintf('The probability of 2e6 or less is %f %%.\n', prob)
title(message)
uiwait(helpdlg(message));
  1 comentario
Stirling Ellis
Stirling Ellis el 27 de Abr. de 2022
This helped me so much. Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by