# [R] Plot bivariate joint pdf

David Winsemius dwinsemius at comcast.net
Mon May 11 18:37:01 CEST 2009

```On May 11, 2009, at 9:46 AM, Ben Bolker wrote:

>
>
>
> beetle2 wrote:
>>
>> For a homework question.
>> I was wondering if rcmdr has a function to plot a graph of a
>> bivariate
>> function of X and Y.
>> I have a function with joint pdf
>>
>> fX,Y(x,y) = x+y for 0<x<1  , 0<y<1
>>
>> I've tried
>>> x <- seq(0,1,.001)
>>> y <- seq(0,1,.001)
>>> r = x+y
>>> plot(r)
>>
>> but it seems to just add them together say .2+.2 .3+.3  not other
>> possibilities like
>>
>> .9 + .1
>>
>>
>
> We don't do homework questions here, but a few hints:
>
> (1) the question doesn't seem to be fully specified.  Are x and y
> supposed
> to be uniform?
>
> (2) you could get a reasonable representation of the solution
> (although
> not necessarily one your prof would be happy with) by adding
> runif(10000,0,1) and runif(10000,0,1)
>
> (3) to do this analytically, think about convolutions and/or moment
> generating functions.

(4) ?integrate
and search on "double integration".

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

```