[R] Plot bivariate joint pdf
beetle2
samandbrendan at aapt.net.au
Thu May 14 03:56:52 CEST 2009
Hi All,
Thankyou for your sugestions,
I Look through some other posts and learnt about the
persp() function.
So I ended up using;
x <- seq(0, 1, len = 20)
y <- seq(0, 1, len = 20)
model = function (x, y){
x+y}
z=outer(x, y ,model);
persp(x,y,z,theta=30,phi=30,ticktype="detailed")
Worked a real treat.
Thankyou all
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.
>
> Ben Bolker
>
>
--
View this message in context: http://www.nabble.com/Plot-bivariate-joint-pdf-tp23481872p23533005.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list