28
$\begingroup$

I'm working with two independent normal distributions $X$ and $Y$, with means $\mu_x$ and $\mu_y$ and variances $\sigma^2_x$ and $\sigma^2_y$.

I'm interested in the distribution of their ratio $Z=X/Y$. Neither $X$ nor $Y$ has a mean of zero, so $Z$ is not distributed as a Cauchy.

I need to find the CDF of $Z$, and then take the derivative of the CDF with respect to $\mu_x$, $\mu_y$, $\sigma^2_x$ and $\sigma^2_y$.

Does anyone know a paper where these have already been calculated? Or how to do this myself?

I found the formula for the CDF in a 1969 paper, but taking these derivatives will definitely be a huge pain. Maybe someone has already done it or knows how to do it easily? I mainly need to know the signs of these derivatives.

This paper also contains an analytically simpler approximation if $Y$ is mostly positive. I can't have that restriction. However, maybe the approximation has the same sign as the true derivative even outside the parameter range?

$\endgroup$
  • 4
    $\begingroup$ I have added $\TeX$ for you. You wrote "sigma" but mentioned that these were variances, so I made them sigma-squared. Make sure it still says what you want to ask. $\endgroup$ – gung - Reinstate Monica Jul 25 '12 at 23:17
  • 3
    $\begingroup$ en.wikipedia.org/wiki/Ratio_distribution has the probability density function. $\endgroup$ – Douglas Zare Jul 26 '12 at 0:38
  • 2
    $\begingroup$ That's the same PDF as in the paper above. I'm trying to take the derivative of the CDF with respect to the underlying mus and sigmas. $\endgroup$ – ABC Jul 26 '12 at 1:14
  • 2
    $\begingroup$ The formula of the pdf found by David Hinkley is completely in closed-form. So you can take those derivatives, one step at a time. I am actually curious about the point of doing such derivations as there is no reason the sign should be constant uniformly over the real numbers... $\endgroup$ – Xi'an Jul 26 '12 at 7:43
  • 2
    $\begingroup$ @ABC You can find the density of $X/Y$ in equation 1 of this paper. I worked on it some time ago and it agrees with Hinkley's result and Marsaglia's result. It can be deduced by brute force as well as Douglas Zare suggests (I did it, only recommended if you really need to do it). $\endgroup$ – user10525 Jul 26 '12 at 9:16
1
$\begingroup$

Some related papers:

Wiki: `http://en.wikipedia.org/wiki/Ratio_distribution

  1. http://www.jstatsoft.org/v16/i04/

  2. http://link.springer.com/article/10.1007/s00362-012-0429-2

  3. http://mrvar.fdv.uni-lj.si/pub/mz/mz1.1/cedilnik.pdf

$\endgroup$
  • 5
    $\begingroup$ Welcome to the site, @Quantum. Would you mind giving a brief summary of these papers, so that readers can judge whether they are what they're looking for without having to open & read each one? $\endgroup$ – gung - Reinstate Monica Jan 22 '14 at 1:16
  • $\begingroup$ @gung Yes, I mind ... Just kidding. These are the newest papers on the topic, containing the expression for the density of $Z=X/Y$, to the best of my knowledge. The topic is not that hot, so it's likely that this list is up-to-date unless you are reading this on year 2527. $\endgroup$ – Quantum Jan 22 '14 at 1:22
  • 4
    $\begingroup$ Quantum - That doesn't address @gung's concern. Link-only answers aren't usually acceptable. Gung has asked if you could 'give a brief summary of these papers' (meaning 'in your answer'). Your collective description in a comment isn't sufficient. Please give a brief description of each link (if possible, individually, not collectively) that would indicate why you included it/why it's relevant. As it stands your potentially useful answer risks being converted to a comment -- as has already happened with earlier link-only responses to this question. $\endgroup$ – Glen_b -Reinstate Monica Jan 22 '14 at 2:29
  • $\begingroup$ I don't understand why the expectation of the ratio doesn't exist. If $ X $ and $ Y $ are jointly normally distributed with mean different than zero, then the mean of $ Z = \frac{X}{Y} $ is given by $ \int \int \frac{x}{y} p \left( x, y \right) dx dy $, what am I missing? $\endgroup$ – Royi Apr 13 '15 at 18:41
  • $\begingroup$ Whay you are missing is the fact tha the density of $y$ is continuous and positive at zero, so that there is generated heavy tails ... $\endgroup$ – kjetil b halvorsen Aug 30 '15 at 12:16
0
$\begingroup$

Consider using a symbolic math package like Mathematica ,if you have a license, or Sage if you don't.

If your just doing numerical work, you might also just consider numerical differentiation.

While tedious, it does look straight forward. That is, all of the functions involved have easy to compute derivatives. You might use numerical differentiation to test your result when you are done to be sure you have the right formula.

$\endgroup$
0
$\begingroup$

This is the sort of problem that is very easy numerically, and less error prone as well. Since you say you only need the signs, I assume that accurate numerical approximations are more than sufficient for your needs. Here is some code with an example of the derivative against $\mu_x$:

pratio <- function(z, mu_x=1.0, mu_y=1.0,var_x=0.2, var_y=0.2) {
    sd_x <- sqrt(var_x)
    sd_y <- sqrt(var_y)

    a <- function(z) {
        sqrt(z*z/var_x+1/var_y)
    }

    b <- function(z) {
        mu_x*z/var_x + mu_y/var_y
    }

    c <- mu_x^2/var_x + mu_y^2/var_y

    d <- function(z) {
        exp((b(z)^2 - c*a(z)^2)/(2*a(z)^2))
    }


    t1 <- (b(z)*d(z)/a(z)^3)
    t2 <- 1.0/(sqrt(2*pi)*sd_x*sd_y)
    t3 <- pnorm(b(z)/a(z)) - pnorm(-b(z)/a(z))
    t4 <- 1.0/(a(z)^2*pi*sd_x*sd_y)
    t5 <- exp(-c/2.0)
    return(t1*t2*t3 + t4*t5)
}

# Integrates to 1, so probably no typos.
print(integrate(pratio, lower=-Inf, upper=Inf))

cdf_ratio <- function(x, mu_x=1.0, mu_y=1.0,var_x=0.2, var_y=0.2) {
    integrate(function(x) {pratio(x, mu_x, mu_y, var_x, var_y)}, 
        lower=-Inf, upper=x, abs.tol=.Machine$double.eps)$value
} 

# Numerical differentiation here is very easy:
derv_mu_x <- function(x, mu_x=1.0, mu_y=1.0,var_x=0.2, var_y=0.2) {
    eps <- sqrt(.Machine$double.eps)
    left <- cdf_ratio(x, mu_x+eps, mu_y, var_x, var_y)
    right <- cdf_ratio(x, mu_x-eps, mu_y, var_x, var_y)
    return((left - right)/(2*eps))
} 
$\endgroup$

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.