Check whether a function of two variables is a probabilty distribution function

I have a function like this

$f(x,y)=c\,y\,(y-x),\ \text{for}\ 0<x<2,\;-x<y<x$

and I need to find the value of $c$ such that $f(x,y)$ is a PDF.

How can I do that?

I know that the condition is double integral $f(x,y)=1$, but how can I impose that condition with Mathematica?

• Hello xmpirate! It is not clear that your question is about using the Mathematica software. Please indicate what you have tried, including any code that is not working for you. Belisarius has given an example in his answer, but perhaps your question is about something else. It is not very clear. Oct 3 '13 at 2:27

You forgot the prior condition that the density must not be negative.
There are two solutions, depending on the sign of c.

If c is positive then Reduce[y(y-x) >= 0 && 0 < x < 2 && -x < y < x, {x,y}]

0 < x < 2 && -x < y < 0

gives the region over which f is non-negative, and c = 1/Integrate[y(y-x), {x,0,2}, {y,-x,0}]

3/10

If c is negative then Reduce[y(y-x) <= 0 && 0 < x < 2 && -x < y < x, {x,y}]

0 < x < 2 && 0 < y < x

gives the region over which f is non-negative, and c = 1/Integrate[y(y-x), {x,0,2}, {y,0,x}]

-3/2

s = Solve[Integrate[c y (y - x), {x, 0, 2}, {y, -x, x}] == 1]

Plot3D[c y (y - x) /. s[], {x, 0, 2}, {y, -x, x}, PlotRange -> All, Mesh -> None,
PlotStyle -> Directive[Orange, Specularity[White, 40]], Filling -> Bottom]

(* {{c -> 3/8}} *) • what is the range of y. Oct 3 '13 at 1:44

The double integral gives a very simple value in terms of $c$

Integrate[c y (y - x), {x, 0, 2}, {y, -x, x}]
8 c/3

so the equation to be solved is a trivial one

8 c/3 == 1

that we can solve in our heads to get $c=\frac{3}{8}$.

Or just:

1/Integrate[y (y - x), {x, 0, 2}, {y, -x, x}]