How to draw a density function?
조회 수: 2 (최근 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!