Hw in matlab about joint probability >>> need help

  1. 1. The problem statement, all variables and given/known data
    i'd try to write the code for this question :(Discrete random variable X & Y have a joint distribution : Fx,y(x,y)=0.1u(x+4)u(y-1)+0.1u(x+3)u(y+5)+0.17u(x+1)u(y-3)+0.05u(x)u(y-1)+0.18u(x-2)u(y+2)+0.23u(x-3)u(y-4)+0.12u(x-4)u(y+3)


    2. Relevant equations
    I try this code in matlab but it doesn't work :
    >> x=[-4 -3 -1 0 2 3 4];
    >> y=[1 -5 3 1 -2 4 -3];
    >> [X Y] = meshgrid(x,y);
    >> Z =0.1.*heaviside(x+4).*heaviside(y-1)+0.15.*heaviside(x+3).*heaviside(y+5)+0.17.*heaviside(x+1).*heaviside(y-3)+0.05.*heaviside(x).*heaviside(y-1)+0.18.*heaviside(x-2).*heaviside(y+2)+0.23.*heaviside(x-3).*heaviside(y-4)+0.12.*heaviside(x-4).*heaviside(y+3);


    3. The attempt at a solution
    please can you figure where is the problem ???
    1. The problem statement, all variables and given/known data



    2. Relevant equations



    3. The attempt at a solution
     
  2. jcsd

  3. The question you stated is a statement. What are you supposed to do in MATLAB with that given information?
     
    Last edited: Mar 31, 2012
  4. i want the sketch for the joint cdf in matlab
     
  5. A few things to mention:
    You want to have a large grid of values to evaluate your 2d function. You do not want only the values where you have a jump in your cdf. So forget your definition of x and y. Instead, say [X Y] = meshgrid(-6:.01:6, -6:01:6); Or something similar. You want to have a nice xy sampling of your function, so size your x and y appropriately. If your function is grainy or inaccurate, you can bump up the step in between samples.

    Second, you may want to avoid using the heaviside definition in MATLAB and simply write your own unit step. In probability, we think of gaining all of the probability at the exact instant the impulse is evaluated. For example, if you had two impulses, one nonzero at x = 1 and the other at x = 3, both of height .5, you would expect p[x <= 1] = .5. You would not expect it to be .25 (which the MATLAB heaviside will give you). Since there are hundreds of points, and only a few of them will invoke the 1/2 definition of the MATLAB heaviside (in conjunction to being right next to a multitude of 1.0 evaluations), it may not be an issue. Just do the plot and make sure you don't see an odd half step before each real step.

    Third, there are numerous functions in MATLAB to do 3d plots for various applications. I just ran a Google search and arrived to surf(X,Y,Z). I also plugged in a meshgrid and your function, and it created what I would expect. Here is a reference of a list of 3d plotting functions native to MATLAB:
    http://www.mathworks.com/help/techdoc/ref/mesh.html

    Use the navigator on the left to explore your options.
     
Know someone interested in this topic? Share a link to this question via email, Google+, Twitter, or Facebook

Have something to add?
Similar discussions for: Hw in matlab about joint probability >>> need help
Loading...