I'm trying to model the joint pdf of (X,Y) from example 4.5.8 of the text Statistical Inference 2nd Edition, Casella, Berger (pg 199 of the pdf). Essentially,

X ~ Uniform[0,1]

Z ~ Unfiorm[0,1/10]

Y ~ X + Z

I want to make a 3D plot of the joint pdf (X,Y)

Here is what I have accomplished thus far:

n = 1000;
X = RandomVariate[UniformDistribution[{0, 1}], n];
Z = RandomVariate[UniformDistribution[{0, 1/10}], n];
Y = X + Z;
XY = Transpose[{X, Y}];

Which gives the plot similar to Fig 4.5.1 (b):

enter image description here

However, I would somehow like to use

Y = TransformedDistribution[
X + Z, {X \[Distributed] UniformDistribution[{0, 1}], 
Z \[Distributed] UniformDistribution[{0, 1/10}]}];

To actually make a 3D plot of the joint pdf. I know about the Product Distribution function, but I'm not sure if it's applicable in this scenario as my random variables are not independent (Y depends on X).


1 Answer 1


my random variables are not independent (Y depends on X)

You can still use TransformedDistribution[]:

dist = TransformedDistribution[{x, x + z},
                               {x \[Distributed] UniformDistribution[{0, 1}], 
                                z \[Distributed] UniformDistribution[{0, 1/10}]}];

{BlockRandom[SeedRandom[42]; ListPlot[RandomVariate[dist, 1000]]], 
 Plot3D[PDF[dist, {x, y}] // Evaluate, {x, 0, 1}, {y, 0, 1}]} // GraphicsRow

simulation and PDF

  • $\begingroup$ This is great! Thanks for adding your code as I will hopefully be able to apply it to similar problems in the future. $\endgroup$
    – TensorFlow
    Commented Oct 25, 2017 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.