I'm working on distributions for a physics problem and I am quite stumped on how to proceed properly.

The problem is as follows: I start at the point $(0,0)$ and go a distance $\eta$ in x direction $(\eta, 0)$, from there I go in a random direction $\phi$ (uniformly distributed) a distance $x$ that is gaussian distributed. I need the distribution of $y$, with $y$ being the distance of the resulting point from $(0,0)$

To formalize that:


(is the distribution of the random x direction) but I also know that

$y = \sqrt{2 x \eta \cos (\phi )+\eta ^2 + x^2}$

with $\phi$ being uniformly randomly distributed between $0, 2\pi$

Is it correct to say (with performing change of variables between x to y, and phi:

$g(y, \phi)\propto f(x)|\frac{dx}{dy}||\frac{dx}{d\phi}|$?

I'm pretty sure this is wrong (I suppose I need the Jacobian in some way), but I can't find good references for it

  • 1
    $\begingroup$ The modern theory of changes of variable in integration (dating to about 1900) is outlined at stats.stackexchange.com/questions/36093. An older theory (based on "Jacobians") is illustrated in many posts here. For intuitive explanations, see stats.stackexchange.com/questions/14483. Maybe that answers your question? $\endgroup$
    – whuber
    May 29 at 12:36
  • $\begingroup$ You are right about your expression being wrong (it's not even a density function - the derivatives can be negative, and the whole thing doesn't integrate to 1). In general it is impossible to determine the joint distribution of two variables from their individual marginal distributions $\endgroup$
    – J. Delaney
    May 29 at 14:01
  • $\begingroup$ Sorry sloppy physicist here. I changed my question accordingly. On a general level i will be out of luck here? Or is there a general approach i could take? $\endgroup$
    – wa4557
    May 29 at 15:51
  • 3
    $\begingroup$ What physical problem is underlying here? When I reverse engineer this then I can model this as the distance between the origin and a random point on a circle with radius $\eta$ and midpoint $(0,x)$ where $x$ follows a normal distribution with standard deviation $b$. But possibly you meant to model the situation with a midpoint $x_1,x_2$ that is bivariate normal distributed? In that case $f(x)$ should be a chi-distribution with two degrees of freedom instead of one, and the distribution of $y$ is related to the rice distribution. $\endgroup$ May 29 at 20:53
  • 1
    $\begingroup$ In your edit you write "from there I go in a random direction 𝜙 (uniformly distributed) a distance 𝑥 that is gaussian distributed". To me this seems like a very unlikely problem situation. What sort of physics is generating this problem? $\endgroup$ May 30 at 12:41

3 Answers 3


Whuber gave an answer to the question about the coordinate transformation. But in the final two sentences of his answer he noted

Finally, I suspect that this is just one step in the solution of a problem that, if it were disclosed, might be (much) simpler to solve some other way. Analyzing the density of $(Y,\Phi)$ is not an appetizing prospect.

In your recent edit you disclosed that you are not after the joint distribution $f_{Y,\Phi}(y,\phi)$ but instead after the marginal distribution $f_Y(y)$.

In this answer we show one of those other more simple ways how to solve it without directly tackling the solution for the joint density distribution.

When I reverse engineer this, then I can model this as the distance $y$ between the origin and a random point on a circle with radius $\eta$ and midpoint $(0,x)$ where $x$ follows a normal distribution with standard deviation $b$.

Instead of computing the distribution density it might be easier to compute the cumulative distribution.

We can consider the values of $x$ and $\phi$ for which the point on the circle is still below a distance $y$ (ie. $f(x,\phi)<y$) and integrate over that area.

We can do this by considering for every point $x$ how much of the circle of radius $\eta$ centered at $0,x$ is intersecting with the circle of radius $y$ centered at $0,0$. Then integrate over all $x$ while multiplying with the fraction of the circle that intersects inside the circle of radius $y$.

$$F(Y<y) = 2 \int_{max(\eta-y,y-\eta)}^{y+\eta} \frac{1}{b\sqrt{\pi}} e^{-\frac{x^2}{b^2}} \overbrace{\frac{1}{\pi} cos^{-1}\left(\frac{x^2+\eta^2-y^2}{2x\eta}\right)}^{\text{fraction of circular segment intersecting}}dx + 2\int_0^{max(0,y-\eta)} \frac{1}{b\sqrt{\pi}} e^{-\frac{x^2}{b^2}} dx$$

To get the distribution density you differentiate the above. For this you can use Leibniz integral rule and you will get several terms because not only the integrand is dependent on $y$ but also the integration limits (but since the integrand is zero at the limits, or cancels, these terms will be zero as well).

If I do this then I get to

$$f(y) = 2 \int_{abs(y-\eta)}^{y+\eta} \frac{1}{b\sqrt{\pi}} e^{-\frac{x^2}{b^2}} \frac{1}{\pi} \frac{y}{x\eta}\frac{1}{\sqrt{1-\left(\frac{x^2+\eta^2-y^2}{2x\eta}\right)^2}}dx $$


$$f(y) = \frac{y}{b\pi^{3/2}} \int_{abs(y-\eta)}^{y+\eta} e^{-\frac{x^2}{b^2}} \frac{1}{\sqrt{x^2-(y-\eta)^2}\sqrt{(y+\eta)^2-x^2}}dx $$

Demonstration with computational simulation

Below is a histogram for a simulation of size $n=10^4$ with parameters $\eta= 1$ and $\sigma = b/\sqrt{2} = 1$. Superimposed is a computation of the density distribution based on a differentiation of the formula above.


### settings
n = 10^4
eta = 1
sig = 1

### simulate and plot histogram
phi = runif(n,0,2*pi)
x = rnorm(n,0,sig)
y = sqrt(eta^2+x^2+2*x*eta*cos(phi))

hist(y, freq=0, breaks = seq(0,5,0.1))

### integrand function
integrand = function(x,z) {
    ### exit for special cases to prevent NA values for acos
    if (x-eta>=z) {
    if (x+eta<=z) {
integrand = Vectorize(integrand)

### compute density by integrating integrand
pcomp = function(z) {
 d = 0.001
 xi = seq(abs(z-eta),z+eta,d)
 2*sum(integrand(xi,z))*d + 2*(pnorm(max(0,z-eta))-0.5)
pcomp = Vectorize(pcomp)

### compute cumulative distribution and differentiate for density
dd = 0.05
zs = seq(0,5,dd)
  • $\begingroup$ +1 Excellent answer! For whatever it's worth when I use your formula for the cdf I can only come up with single symbolic result and that's when $y=\eta$: $\frac{4 \eta \, _2F_2\left(\frac{1}{2},1;\frac{3}{2},\frac{3}{2};-\frac{4 \eta ^2}{b^2}\right)}{\pi ^{3/2} b}$. $\endgroup$
    – JimB
    May 29 at 23:56
  • $\begingroup$ @JimB This function is, practically by definition, an elliptic integral. $\endgroup$
    – whuber
    May 30 at 12:56
  • $\begingroup$ Sextus: The reason I didn't go here is that the density likely is wrong. Because it's impossible for a distance to have a Gaussian distribution, I suspect the OP means $x$ is a polar coordinate for a Bivariate Gaussian position. If so, $f$ needs to be multiplied by $x\mathcal{I}(x\gt 0)$ (and renormalized). Here is a quick simulation of this interpretation: xy <- matrix(rnorm(n <- 1e4, c(eta <- 1,0), b <- 1), 2) hist(r <- sqrt(xy[1,]^2 + xy[2,]^2)) (I see you are asking the OP related questions...) $\endgroup$
    – whuber
    May 30 at 13:04
  • $\begingroup$ @Whuber, technically the density is not wrong. It is not the distance which is Gaussian distributed, but it is the variable $x$. It is just that this variable can be interpreted as a distance. $\endgroup$ May 30 at 13:30
  • 1
    $\begingroup$ But, I have the same idea that the underlying problem might relate to a bivariate normal distribution and not a single variate normal distribution. I am puzzled about this problem where the radius is normal distributed and looked for a distribution of the Cartesian coordinates that relates to it and got something weird as a distribution for the coordinates like $f(x) \propto e^{-x^2/4} K_0(x^2/4)$ (I don't remember exactly I puzzled it on my phone and the notes got lost). $\endgroup$ May 30 at 13:30

Let $(X,\Phi,Y)$ be the random variables in question. Let's suppose $X$ and $\Phi$ are independent. $Y$ is a function of those two,

$$Y = f_\eta(X,\Phi)=\sqrt{2X\eta\cos(\Phi) + \eta^2+X^2}$$

for some number $\eta \ge 0.$ (If $\eta \lt 0,$ negating both it and $X$ does not change the distribution of $X$ and places us into the $\eta \gt 0$ situation.) That is, when $X\ge 0,$ $Y$ is the length of the third side of a triangle of side lengths $\eta$ and $X$ with included angle $\Phi;$ and when $X\le 0,$ $Y$ is the length of the third side of a triangle of side lengths $\eta$ and $-X.$ This shows the formula makes sense (we're not trying to find the root of a negative number) and that it is almost everywhere a two-to-one mapping, because

$$f_{\eta}(X,\Phi) = f_{\eta}(-X,\Phi+\pi).$$

The question appears to ask for the joint density function of $(Y,\Phi) = (f_\eta(X,\Phi), \Phi).$

We may easily write the joint density of $(X,\Phi),$ because independence implies the joint density is the product of the univariate densities. The joint probability element therefore is (up to sign)

$$f_{X,\Phi}(x,\phi) = \frac{1}{b\sqrt{\pi}} e^{-x^2/b^2}\,\mathrm{d}x \frac{1}{2\pi}\,\mathrm{d}\phi.\tag{*}$$

To change the coordinates, notice the definition of $Y$ implies

$$y^2 - x^2 - \eta^2 - 2x\eta\cos(\phi)=0.$$

From this we obtain $x$ and $x^2$ (sort of, up to a choice of two solutions) as

$$x = -B(\phi,\eta) \pm \sqrt{\Delta(\phi,\eta,y)}\tag{1a}$$


$$x^2 = B(\phi,\eta)^2 + \Delta(\phi,\eta, y) \mp 2B(\phi,\eta)\sqrt{\Delta(\phi,\eta, y)}\tag{1b}$$

where $B(\phi,\eta) = \eta\cos(\phi)$ and $\Delta(\phi,\eta, y) = \eta^2\cos^2(\phi) + (y^2-\eta^2).$

Differentiating (with respect to the variables $(y,x,\phi)$) we also find

$$0 = \mathrm{d}\left(y^2 - x^2 - \eta^2 - 2x\eta\cos(\phi)\right) = 2y\mathrm{d}y - 2x\mathrm{d}x - 2\eta\cos(\phi)\mathrm{d}x + 2x\eta\sin(\phi)\mathrm{d}\phi.$$


$$0 = 0\wedge \mathrm{d}\phi = 2y\mathrm{d}y\wedge\mathrm{d}\phi - (2x + 2\eta\cos(\phi))\mathrm{d}x\wedge\mathrm{d}\phi,$$

which we can solve (almost everywhere) to convert the original differential element $\mathrm{d}x\mathrm{d}\phi$ to the new variables,

$$\mathrm{d}x\mathrm{d}\phi = \frac{y}{x + \eta\cos(\phi)}\,\mathrm{d}y\mathrm{d}\phi.\tag{2}$$

Plugging $(2)$ into $(*)$ gives an expression for the joint probability element $f_{Y,\Phi})(y,\phi)\mathrm{d}y\mathrm{d}\phi$ in which "$x$" and "$x^2$" can be replaced by expressions $(1a)$ and $(1b),$ respectively.

Finally, because the map from $(X,\Phi)$ to $(Y,\Phi)$ is two-to-one, we must double the preceding result: that's the answer.

I'm not going to work this out further for several reasons. One is that the many-to-one transformation suggests the problem hasn't been stated quite as clearly as it ought to be. Another is that in the question, the expression given for the density of $X$ is incorrect. I have silently fixed it above, assuming the intention is that $X$ have a Normal distribution: but perhaps that's the wrong assumption. A change in the density of $X$ would not change how the answer is worked out, but it would change the details of the final answer. Finally, I suspect that this is just one step in the solution of a problem that, if it were disclosed, might be (much) simpler to solve some other way. Analyzing the density of $(Y,\Phi)$ is not an appetizing prospect.


$$ \begin{aligned} g_Y(y) &=\int_0^{2\pi} \frac{d\phi}{2\pi} \int_{-\infty}^{\infty} dx \frac{1}{b\sqrt{\pi}} \exp(\frac{-x^2}{b^2}) \times \\ & ~~~~~~~~~~~~~~~~~~~~~\times \delta \bigg( y-\sqrt{2x\eta\cos{\phi}+\eta^2+x^2} ~~\bigg) \\ &=\int_0^{2\pi} \frac{d\phi}{2\pi} \frac{1}{b\sqrt{\pi}}\exp{\frac{-\tilde{x}^2}{b^2}}\frac{1} {| \frac{\partial}{\partial x }\sqrt{2x\eta\cos{\phi}+\eta^2+x^2}|_{x=\tilde{x}}|}\\ &\text{where }\tilde{x} \text{ solves } \\ y^2 &= 2\tilde{x}\eta \cos{\phi}+\tilde{x}^2+\eta^2 ~ \\ \end{aligned} $$ Complete the square and solve for $\tilde{x}: y^2=2\tilde{x}\eta\cos{\phi}+\eta^2+\tilde{x}^2$ for $\tilde{x}$ in terms of $\phi, y,$ and $\eta$. And now the work begins . . .

But the integral looks vaguely familiar. $\sqrt{2x\eta\cos{\phi}+\eta^2+x^2} $ is screaming out to be $Y=|X+\eta|_2$, or the distribution of the Euclidean length of $X+\eta$ where $X$ and $\eta$ are in $\mathbb{R}^d$ and $\phi$ is simply the angle between them. It suggests that there is an earlier statement of this problem that might yield geometrical transformation and a much easier problem to solve. Maybe not, but you never know.

  • $\begingroup$ Two subtleties cannot be ignored: the first concerns why you only differentiate the transformation with respect to $x$ when it also involves $\phi.$ The second concerns the fact that this transformation is not one-to-one. $\endgroup$
    – whuber
    May 29 at 18:21
  • 1
    $\begingroup$ @whuber 1) I did the $x$ integral first. That's a free choice. $\phi$ & its pdf remain in the integrand &are the subject of the 2nd integral. 2) You're right that I ignored the multivalued nature of the sqrt. I was hoping the OP would give whole problem domain, which seems like the distrib of the distance from a random walker starting in, say, $\mathbb{R}^2$ that starts at point $\eta$, proceeds $X$ relative to $\eta$, & then we seek the distance from $\eta+X$ to the origin. If that's the problem, then the problem decomposes into sub problems: walk par & perp to $\eta$ then pythagorean thm. $\endgroup$ May 29 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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