Effacer les filtres
Effacer les filtres

Normal Distribution and area under the curve

18 vues (au cours des 30 derniers jours)
Kyle Langford
Kyle Langford le 5 Mar 2022
Commenté : David Hill le 5 Mar 2022
Hello, I am just looking to make my hw a little fancier than is needed.
The question is asking to find the % of drivers that will get a ticket, if tickets are issued 72mph and above, with a mean speed of 67.
clear;clc;
x_bar=67; %mph
x_ticket=72; %mph that will receive a ticket
s=4; %standard deviation
z1=(x_ticket-x_bar)/s;
pz=0.3944; %from table 4.3
disp('The percent of drivers exceeding 72mph is')
P=(0.5-pz)*100
rng(0,'twister')
a=4; %standard deviation
b=67; %mean value
y=a.*randn(1000,1)+b;
pd=fitdist(y,'Normal')
x=[-3:.1:3]; %+/- 15 from the mean
y=normpdf(x,0,1);
plot(x,y)
I think I am rpetty close. I just want to figure out how to get MATLAB to plot this data, and shade the ticketed region. Like the picture below.
furthermore, extra points, how can i get the area under the curve?
Thanks!
R2022a (beta)

Réponse acceptée

David Hill
David Hill le 5 Mar 2022
mu=67;
sigma=4;
x=72;
y =1 - cdf('Normal',x,mu,sigma)
  2 commentaires
Kyle Langford
Kyle Langford le 5 Mar 2022
Certainly that is a better way to solve it than what I did! but that was not my question.
My question is, how do I plot this data, and shade it, like the example picture.
David Hill
David Hill le 5 Mar 2022
Likely lots of ways of doing it. I just picked the first thing that came to my mind.
mu=67;
sigma=4;
x=67-4*sigma:.1:67+4*sigma;
y =pdf('Normal',x,mu,sigma);
plot(x,y)
hold on
bar(x(x>=72),y(x>=72),'FaceColor','b','EdgeColor','b');

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by