Computing exact distributions part 3

Author

Giovanni Forchini

Published

September 17, 2023

The change of variable formula and transformations

We now study how the integral changes when we transform the variable of integration according to the rule \(x = x\left( y \right)\). When we transform \(x\) to \(y\) we need this transformation to be one-to-one. That is, \(x\) transforms into one \(y\) and it is also possible to transform back \(y\) to \(x\) in a unique way.

We start by considering the case where \(n=1\).

In this case the integral is \(\int\limits_{\left( {a,b} \right)} {f\left( x \right)dx}\). We need to understand how this integral changes:

  • The interval \(\left( {a,b} \right)\) is transformed to the interval \(\left( {{a^*},{b^*}} \right)\) in such a way that \(x\left( {\left( {{a^*},{b^*}} \right)} \right) = \left( {a,b} \right)\).

  • The function \(f\left( x \right)\) changes to \(f\left( {x\left( y \right)} \right)\), and the volume element becomes \(dx\left( y \right) = x'\left( y \right)dy\).

Thus \[\int\limits_{\left( {a,b} \right)} {f\left( x \right)dx} = \int\limits_{\left( {{a^*},{b^*}} \right)} {f\left( {x\left( y \right)} \right)x'\left( y \right)dy}.\]

This is the transformation of variable formula for an integral.

Suppose for simplicity that \(f\left( x \right) = 1\) so that the integral we are interested in is \(\int\limits_{\left( {a,b} \right)} {dx}\), and suppose we transform \(x\) according to the rule \(x = y\) then \[\int\limits_{\left( {a,b} \right)} {dx} = \int\limits_{\left( {a,b} \right)} {dy} = b - a.\] If, instead, we transform \(x\) according to the rule \(x = - y\) we obtain \[\int\limits_{\left( {a,b} \right)} {dx} = \int\limits_{\left( { - a, - b} \right)} {\left( { - 1} \right)dy} = - \int\limits_{\left( { - a, - b} \right)} {dy} = - \left( { - b - \left( { - a} \right)} \right) = b - a.\]

Note that in this case the length of the interval \(\left( { - a, - b} \right)\) is \(\left( { - b - \left( { - a} \right)} \right) = - \left( {b - a} \right)\) because it is measured in the direction left to right, even though this integral is essentially the same as the one on \(\left( {a,b} \right)\).

We want to disregard these niggling problems with the sign so we want to transform \(\left( {a,b} \right)\) to \(\left( {{a^*},{b^*}} \right)\) with \({a^*} < {b^*}\) for any transformation. To be consistent with the definition of integral we need to transform the volume element to \[dx\left( y \right) = \left| {x'\left( y \right)} \right|dy\] where we take the absolute value of \(x'\left( y \right)\). In this notation, when we transform x according to the rule \(x = - y\) we obtain \[\int\limits_{\left( {a,b} \right)} {dx} = \int\limits_{\left( { - b, - a} \right)} {\left| { - 1} \right|dy} = \int\limits_{\left( { - b, - a} \right)} {dy} = \left( { - a - \left( { - b} \right)} \right) = b - a.\] This convention will be very useful when we look at multivariate integrals over a set \(A\) because we can disregard the direction along which the integral needs to be taken.

When we transform to according to \(x = x\left( y \right)\), then \(A\) changes to \({A^*}\) in such a way that \(A = x\left( {{A^*}} \right)\) and \(f\left( x \right)\) changes to \(f\left( {x\left( y \right)} \right)\). There are some small complications with the volume element. Notice that every component of \(x\) transforms as follows \({x_i} = {x_i}\left( {{y_1},{y_2},...{y_n}} \right)\). So the differential of \({x_i}\) is \[d{x_i} = \frac{{\partial {x_i}}}{{\partial {y_1}}}d{y_1} + \frac{{\partial {x_i}}}{{\partial {y_2}}}d{y_2} + ... + \frac{{\partial {x_i}}}{{\partial {y_n}}}d{y_n}\] for \(i=1,2,…,n\).

To analyse the problem we consider the case where \(n=2\). In this case \[\begin{array}{l} d{x_1} = \frac{{\partial {x_1}}}{{\partial {y_1}}}d{y_1} + \frac{{\partial {x_1}}}{{\partial {y_2}}}d{y_2}\\ d{x_2} = \frac{{\partial {x_2}}}{{\partial {y_1}}}d{y_1} + \frac{{\partial {x_2}}}{{\partial {y_2}}}d{y_2}. \end{array}\]

Notice that I have changed the notation slightly from \(dx^j\) do \(dx_j\), as this is more often used (above this notation would have been confusing).

Figure 6 gives a geometric interpretation of \(d{x_1}\) and \(d{x_2}\). We saw earlier on that \(d{x_1}d{x_2}\) is the area of the rectangle having \(d{x_1}\) and \(d{x_2}\) as sides. As we noted earlier on, the symbol \(d{x_i}\) can be interpreted as a \(2\)-dimensional vectors, \(d{x_i} = \left( {x_i^1,x_i^2} \right)\) say. The area of the rectangle having \(d{x_1}\) and \(d{x_2}\) as sides is just the determinant of \[\left| {\begin{array}{*{20}{c}} {d{x_1}}\\ {d{x_2}} \end{array}} \right| = \left| {\begin{array}{*{20}{c}} {x_1^1}&{x_1^2}\\ {x_2^1}&{x_2^2} \end{array}} \right|.\] The differentials above suggest that \[\left( {\begin{array}{*{20}{c}} {d{x_1}}\\ {d{x_2}} \end{array}} \right) = \left( {\begin{array}{*{20}{c}} {\frac{{\partial {x_1}}}{{\partial {y_1}}}}&{\frac{{\partial {x_1}}}{{\partial {y_2}}}}\\ {\frac{{\partial {x_2}}}{{\partial {y_1}}}}&{\frac{{\partial {x_2}}}{{\partial {y_2}}}} \end{array}} \right)\left( {\begin{array}{*{20}{c}} {d{y_1}}\\ {d{y_2}} \end{array}} \right).\]

Notice that \[\left| {\begin{array}{*{20}{c}} {d{x_1}}\\ {d{x_2}} \end{array}} \right| = \left| {\begin{array}{*{20}{c}} {\frac{{\partial {x_1}}}{{\partial {y_1}}}}&{\frac{{\partial {x_1}}}{{\partial {y_2}}}}\\ {\frac{{\partial {x_2}}}{{\partial {y_1}}}}&{\frac{{\partial {x_2}}}{{\partial {y_2}}}} \end{array}} \right|\left| {\begin{array}{*{20}{c}} {d{y_1}}\\ {d{y_2}} \end{array}} \right|,\] or in a different notation \[d{x_1}d{x_2} = \left| {\begin{array}{*{20}{c}} {\frac{{\partial {x_1}}}{{\partial {y_1}}}}&{\frac{{\partial {x_1}}}{{\partial {y_2}}}}\\ {\frac{{\partial {x_2}}}{{\partial {y_1}}}}&{\frac{{\partial {x_2}}}{{\partial {y_2}}}} \end{array}} \right|d{y_1}d{y_2}.\]

Figure 6. Geometrical interpreation of \(dx_1\) and \(dx_2\).

In general if we transform the variables according to the rules \(x = x\left( y \right)\) where to , then volume element \(d{x_1}d{x_2}....d{x_n}\) changes according to the rule \[d{x_1}d{x_2}....d{x_n} = J\left( {x \to y} \right)d{y_1}d{y_2}....d{y_n}\] where \(J\left( {x \to y} \right)\) denotes the Jacobian of the transformation of \(x\) to \(y\), and it is given by \[J\left( {x \to y} \right) = \left| {\left[ {\begin{array}{*{20}{c}} {\frac{{\partial {x_1}}}{{\partial {y_1}}}}&{\frac{{\partial {x_1}}}{{\partial {y_2}}}}& \cdots &{\frac{{\partial {x_1}}}{{\partial {y_n}}}}\\ {\frac{{\partial {x_2}}}{{\partial {y_1}}}}&{\frac{{\partial {x_2}}}{{\partial {y_2}}}}& \cdots &{\frac{{\partial {x_2}}}{{\partial {y_n}}}}\\ \vdots & \vdots & \ddots & \vdots \\ {\frac{{\partial {x_n}}}{{\partial {y_1}}}}&{\frac{{\partial {x_n}}}{{\partial {y_2}}}}& \cdots &{\frac{{\partial {x_n}}}{{\partial {y_n}}}} \end{array}} \right]} \right|,\] where in this case \(\left| . \right|\) denotes both the determinant and the absolute value.

To summarise, consider the probability of a set A \[\Pr \left\{ A \right\} = \int\limits_A {pdf\left( x \right)dx}\] and transform the variable of integration according to the rule \(x = x\left( y \right)\). We know that \[\Pr \left\{ A \right\} = \int\limits_{A'} {pdf\left( {x\left( y \right)} \right)J\left( {x \to y} \right)dy}\] where \(A = x\left( {A'} \right)\). So if \(pdf\left( x \right)\) is the density of x, and then transform \(x \to y\) then the density of y is \[pdf\left( y \right) = pdf\left( {x\left( y \right)} \right)J\left( {x \to y} \right).\] We now need to find ways for calculating the jacobian in more complex situations.