$X$ and $Y$ are uniformly distributed over the triangle $T$ in the first quadrant of the $x$-$y$ plane with vertices $(0,0)$, $(1,0)$, and $(0,1)$, so that
$$T=\{(x,y)\mid0\le x\le1,0\le y\le1-x\}$$
The joint PDF is then
$$f_{X,Y}(x,y)=\begin{cases}2&\text{for }(x,y)\in T\\0&\text{otherwise}\end{cases}$$
I'm asked to find various moments, covariance, correlation, etc. which are all easy to find by hand, but I'd like to check my results in Mathematica. Are there built-in symbols that can handle this sort of distribution?
The documentation for UniformDistribution
suggests the support must be a rectangle. Trying to insert 1 - x
as the upper bound on y
gives an incorrect, non-uniform PDF:
PDF[UniformDistribution[{{0, 1}, {0, 1 - x}}], {x, y}]
(* Piecewise[{{(1 - x)^(-1), x >= 0 && y >= 0 && 1 - x >= 0 && 1 - x - y >= 0}}, 0] *)
i.e.
$$f_{X,Y}(x,y)=\begin{cases}\frac1{1-x}&\text{for }(x,y)\in T\\0&\text{otherwise}\end{cases}$$
I know I can define my own PDF f
,
f[x_, y_] := Piecewise[{{2, 0 <= x <= 1 && 0 <= y <= 1 - x}}]
and compute moments and co. by integrating f
accordingly. But is there a way to set up a distribution dist
so that I can check my work with Expectation
or Moment
etc.?