Using Matlab to determine if two random variables are independentIndependence is an important concept in
probability theory. Matlab can be used to determine if two random variables are
independent. Let's consider the two discrete random variables in a previous posting. That is, the random
variables X and Y with joint probability mass function
>> syms x y k fx fy fxy;
>> fxy=(x+y)/32;
>> fx=symsum( fxy, y,1,4);
>> fy=symsum( fxy, x,1,2);
>> fxy == fx*fy
ans =
0
>>
The equality operator is used to determine if the symbolic expressions fxy and fx*fy are equal. The zero value of fxy == fx*fy indicates that the expression is false. (You'll actually see the value 'false' in the workspace window, assuming you're using Matlab 7.x.) So X and Y are not independent. (They are dependent.) If the expression fxy == fx*fy has a value of 1 (i.e., true), then the random variables are independent. It seems that these tricks could be packaged in Matlab function. Perhaps I'll write one when I get the chance. If I do, I'll post it on this weblog. Posted: Sunday - December 04, 2005 at 11:57 AM |
Quick Links
Statistics
Total entries in this blog:
Total entries in this category: Published On: May 23, 2008 09:10 AM |