problems with plotting density function
1 view (last 30 days)
Show older comments
Hi, I have 2 dimensional distribution where one dimension are random binary numbers and the other are random real numbers with support [-2,2]. So the data looks like this:
1.0000 -1.3044
1.0000 -0.5507
1.0000 -1.0699
1.0000 -1.3371
1.0000 0.7970
1.0000 -0.4662
0 -0.7049
0 0.0364
0 -1.0314
1.0000 0.0046
Lets call first column x and second y. I'm interested in plotting objects P(x=1|y<Y) and corresponding density (as functions of Y). I can plot cdf Prob(x=1|y<Y) as function of Y, but I'm having problems with plotting corresponding density. I have tried to do something like this:
m=100;
xpv=linspace(-2,2,m);
for i=2:m
pdf_e(i)=(cdf(xpv(i)h)-cdf(xpv(i-1)))/(xpv(i)-xpv(i-1));
end
where cdf(a) = Prob(x=1|y<a) but it gives me something really strange. (cdf function works fine by the way).Can someone please help me with this.
Thanks, Kenan
0 Comments
Accepted Answer
Roger Stafford
on 4 Dec 2014
In terms of the numerical quantities matlab is dealing with, it is not possible to define a probability density for a discrete-valued variable. The 'density' would have to be infinite in this case at x = 0 or 1 and zero for other values of x but such that its integral with respect to x is 1, in much the same manner as is true with the dirac delta "function". This is something beyond matlab's numerical capabilities and belongs to what is known as "measure theory", so you should not attempt the kind of computation you describe with ordinary arithmetic operations. As you have discovered, they wouldn't make any sense.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!