Jay Liu
2009-May-02 04:23 UTC
[R] Bivariate pdf and marginal pdf of non-standard distributions
Hi, I am trying to find marginal pdfs when joint pdf of two continuous variables is given. Simple case is like this: The joint pdf is f(x,y) = 4xy, x lies between 0 and 1, and y also lies between 0 and 1. I tried following crude way of doing it but it is not complete. Could you post a suggestion to it. Thanks, Jay Liu, University of Tennesse at Knoxville ################## # f(x,y) = 4xy, range of x is (0,1), range of y is (0,1) # Checking if f (x,y) is a joint pdf Pxy<-integrate(function(y) { sapply(y, function(y) { integrate(function(x) { sapply(x, function(x) (4*x*y)) }, 0, 1)$value }) }, 0, 1) print("Value of int int f(x,y)dx dy") Pxy # To find marginal distribution, I tried this, but this is incorrect because x is not all considered while integrating the joint pdf # Assume x to be a constant # Px1 = f(x) Px1<-integrate(function(y) { 4*y }, 0, 1)$value [[alternative HTML version deleted]]