🎥 See More
A function on the plane is called a joint density if:
for all ,
If you think of as a surface, then the first condition says that the surface is on or above the plane. The second condition says that the total volume under the surface is 1.
Think of probabilities as volumes under the surface, and define to be the joint density of random variables and if
That is, the chance that the random point falls in the region is the volume under the joint density surface over the region .
This is a two-dimensional analog of the fact that probabilities involving a single continuous random variable can be thought of as areas under the density curve.
Answer
(ii)
🎥 See More
Infinitesimals¶
Also analogous is the interpretation of the joint density as part of the calculation of the probability of an infinitesimal region.

The infinitesimal region is a tiny rectangle in the plane just around the point . Its width is and its length is . The corresponding volume is that of a rectangular box whose base is the tiny rectangle and whose height is .
Thus for all and ,
and the joint density measures probability per unit area:
An example will help us visualize all this. Let be defined as follows:
For now, just assume that this is a joint density, that is, it integrates to 1. Let’s first take a look at what the surface looks like.
Plotting the Surface¶
To do this, we will use a 3-dimensional plotting routine. First, we define the joint density function. For use in our plotting routine, this function must take and as its inputs and return the value as defined above.
def joint(x,y):
if y < x:
return 0
else:
return 120 * x * (y-x) * (1-y)Now we will call Plot_3d to plot the surface. The arguments are the limits on the and axes, the name of the function to be plotted, and two optional arguments rstride and cstride that determine how many grid lines to use. Larger numbers correspond to less frequent grid lines.
Plot_3d(x_limits=(0,1), y_limits=(0,1), f=joint, cstride=4, rstride=4)
The surface has level 0 in the lower right hand triangle because it is not possible for the point to be in that region.
The possible values of are the blue region shown below. For calculations by hand, we will frequently draw just the possible values and not the surface.

🎥 See More
The Total Volume Under the Surface¶
The function looks like a bit of a mess but it is easy to see that it is non-negative. It’s a good idea to check that the total probability under the surface is equal to 1.
To set up the double integral over the entire region of possible values, notice that for each fixed value of , the value of goes from 0 to . The values of go from 0 to 1.
We will first fix and integrate with respect to . Then we will integrate with respect to . Thus the total integral is
By SymPy¶
To use SymPy we must create two symbolic variables. As our variables are positive, we can specify that as well. Then we can assign the expression that defines the function to the name f. This specification doesn’t say that but we will enforce that condition when we integrate.
x = Symbol('x', positive=True)
y = Symbol('y', positive=True)
f = 120*x*(y-x)*(1-y)
fDisplaying the double integral requires a call to Integral that specifies the inner integral first and then the outer. The call says:
The function being integrated is .
The inner integral is over the variable which goes from 0 to y.
The outer integral is over the variable which goes from 0 to 1.
Integral(f, (x, 0, y), (y, 0, 1))To evaluate the integral, use doit():
Integral(f, (x, 0, y), (y, 0, 1)).doit()Answer
🎥 See More
Probabilities as Volumes¶
Probabilities are volumes under the joint density surface. In other words, they are double integrals of the function . For each probability, we have to first identify the region of integration, which we will do by geometry and by inspecting the event. Once we have set up the integral, we have to calculate its value, which we will do by calculus or SymPy.
Example 1¶
Suppose you want to find . The event is the blue region in the graph below.

To find the region of integration, notice that for fixed , the value of goes from 0 to . So
By SymPy¶
Integral(f, (x, 0, y/4), (y, 0, 1))Integral(f, (x, 0, y/4), (y, 0, 1)).doit()5/32Example 2¶
Suppose you want to find . The event is the colored region below.

Now is the integral of the joint density function over this region. Notice that for each fixed value of , the value of in this event goes from 0.25 to . So let’s integrate first and then , as we did in the previous calculations.
You can crank that out by hand or use SymPy.
Integral(f, (x, 0.25, y), (y, 0.5, 1))Integral(f, (x, 0.25, y), (y, 0.5, 1)).doit()🎥 See More
Expectation¶
Let be a function on the plane. Then
provided the integral exists, in which case it can be carried out in either order: first and then , or the other way around.
This is an application of the non-linear function rule for expectation, applied to two random variables with a joint density.
As an example, let’s find for and with the joint density used in the examples above.
Here , and
By SymPy¶
Remember that x and y have already been defined as symbolic variables that are positive.
ev_y_over_x = Integral((y/x)*f, (x, 0, y), (y, 0, 1))
ev_y_over_xev_y_over_x.doit()