Need to find probability

15 ビュー (過去 30 日間)
Stirling Ellis
Stirling Ellis 2022 年 4 月 27 日
コメント済み: Stirling Ellis 2022 年 4 月 27 日
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!

採用された回答

Image Analyst
Image Analyst 2022 年 4 月 27 日
編集済み: Image Analyst 2022 年 4 月 27 日
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 件のコメント
Stirling Ellis
Stirling Ellis 2022 年 4 月 27 日
This helped me so much. Thank you!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by