How to draw a density function?
1 次查看(过去 30 天)
显示 更早的评论
Suppose I have :
x = 1-2 frequency 5 probability 1/2 x= 2-4 frequency 3 probability 3/10 x = 4-6 frequency 2 probability 2/10
and I want to draw it... how can I do it?
0 个评论
回答(2 个)
Youssef Khmou
2013-4-14
hi,
you mean probability density function ?
try :
doc pdf
For example, you want to draw the Normal PDF over the range [-10:10] with N(0,1):
x=-10:0.1:10;
Y=pdf('norm',x,0,1);
figure, plot(x,Y), title(' Normal distribution N(0,1)');
'pdf' function can draw up to 23 distributions,
0 个评论
Wayne King
2013-4-14
This appears to be a simple discrete random variable with a probability mass function. The problem is that in that case, you cannot have assignments like 1-2, 2-4
The outcome 2 cannot be assigned two different probabilities: 5/10 and 3/10.
Further, this cannot be a distribution with probability assigned to the intervals you give with discontinuities at the interval endpoints because that would not yield a valid probability density function. The total measure (integral) of those step functions would exceed 1.
Here is a valid probability mass function. I'll just assign the probability at the midpoint of the interval (but that may not be correct for your case)
x = [1.5 3 5];
y = [1/2 3/10 2/10];
bar(x,y)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!