Register to reply

Hw in matlab about joint probability >>> need help

Share this thread:
maiad911
#1
Mar31-12, 05:46 PM
P: 2
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
Phys.Org News Partner Science news on Phys.org
Scientists develop 'electronic nose' for rapid detection of C. diff infection
Why plants in the office make us more productive
Tesla Motors dealing as states play factory poker
RoshanBBQ
#2
Mar31-12, 06:22 PM
P: 280
Quote Quote by maiad911 View Post
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

The question you stated is a statement. What are you supposed to do in MATLAB with that given information?
maiad911
#3
Apr2-12, 03:02 AM
P: 2
i want the sketch for the joint cdf in matlab

RoshanBBQ
#4
Apr2-12, 04:20 AM
P: 280
Hw in matlab about joint probability >>> need help

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.


Register to reply

Related Discussions
Probability: joint probability distribution problem? Calculus & Beyond Homework 8
[PROBABILITY] Joint probability function for two DISCRETE variables Calculus & Beyond Homework 1
Joint Probability Set Theory, Logic, Probability, Statistics 3
Joint probability from conditional probability? Set Theory, Logic, Probability, Statistics 10
Joint probability Set Theory, Logic, Probability, Statistics 1