1
$\begingroup$

I have a problem where I have sum of two random variables

1). Each distributed independently normally with different means ($\mu_1$, $\mu_2$) and sds ($\sigma_1$, $\sigma_2$). $Z=R_1+R_2$

2). Each distributed independently log-normally with different means ($u_1$, $u_2$) and sds ($s_1$, $s_2$). $LZ=LR_1+LR_2$

In the first case, the answer lies in (-$\infty$, $\infty$) and (0, $\infty$) in the second case.

I need to transform these random variables i.e. $Z$ and $LZ$ to make them probabilities and lie in [0, 1], as I want to simulate a Bernoulli Trial with that probability.

I see that as a case of remapping probability densities.

For case 1, I think I could use the logistic transform on $Z$ to make it a probability which lies in [0, 1]. I hope that makes sense?

Also, I am clueless regarding how to do this mapping for the case of lognormal distribution?

I would really appreciate any feedback on this!

$\endgroup$
2
$\begingroup$

Since the sum of two independent normals is normal, you wouldn't get a uniform (as in your original title) by applying a logistic transformation on the sum.

  • If the means and variances are known (as your question implies), you could get a uniform result by using the normal cdf of the sum (mean is the sum of means, variance is the sum of variances).

  • If you don't actually want a uniform (as your change in title now indicates), you could use the logistic transform as you suggest, but any cdf of $(-\infty,\infty)$ would do.

In the second case, the sum of two independent lognormals doesn't have a nice closed form.

  • If you're just looking to get it into the range $(0,1)$, any cdf on $(0,\infty)$ can do that (lognormal, gamma, Weibull, F, log-logistic, beta prime, ...). However you could just do $Y/(Y+1)$ -- my $Y$ is your $LZ$ -- to the same effect. I guess that would just be a standard log-logistic cdf transform though. I think this would be equivalent to taking logs and applying the same logistic you would for the normal case.

  • If you want a rough approximation to uniform, take the sum to be lognormal with mean the sum of the means (careful, don't add the log-scale $\mu$ parameters), and variance the sum of the variances (with the corresponding not of caution). This will often work fairly well:

enter image description here
(Code is given below)

By comparison, the problem with just getting the range right is that in practice almost all of the values are likely to end up in a very narrow part of the range:

enter image description here

That's the same sum, transformed by a standard log-logistic cdf. It's certainly in $(0,1)$, but in a sample of 10000 values, all of them were between 0.97 and 0.995. If that's what you want, then you should be okay (keeping in mind that the next one might be piled up the other end - or end up U-shaped, or bunched in the middle). If it's not what you need, then I suggest you at least do some approximate quantile matching or moment matching to get a better spread of values.

  • If you really do want a uniform result (up to reasonable calculation accuracy), you could perhaps make use of numerical convolution.

--

#R code to calculate the lognormal approximation to the sum and transform:

X1 <- rlnorm(10000, 3, .4)
X2 <- rlnorm(10000, 4, .3)
hist(X1, n=100)
hist(X2, n=100)

m1 <- exp(3+.4^2/2)
m2 <- exp(4+.3^2/2)
v1 <- m1^2*(exp(.4^2)-1)
v2 <- m2^2*(exp(.3^2)-1)

Y <- X1+X2
v <- v1+v2
m <- m1+m2
s2 <- log(v/m^2+1)

hist(X1+X2, n=100)
uish <- plnorm(Y,log(m-s2/2),sqrt(s2))
hist(uish, n=100)
$\endgroup$
  • $\begingroup$ Thanks! I changed the title. I just need to be able to simulate bernoulli draws with that probability. It need not be uniform on [0,1]. I guess, then, the logistic should be fine as its simple such cdf? Can you mention any [0, $\infty$] cdfs that I could use for log-normal? $\endgroup$ – Blade Runner Dec 22 '14 at 2:50
  • $\begingroup$ I have updated the answer to list several distributions on $(0,\infty)$. As for whether the logistic would be suitable for your purpose, it's not clear to me what you're trying to achieve overall (it doesn't seem to do anything that I'd want to do that way, but maybe it's sensible and I just don't understand it yet), so I can hardly judge its suitability. Similar comments would apply to the distributions on the positive half-line -- I have no way to judge their suitability to your purpose until I really understand what it's supposed to achieve in the long run. $\endgroup$ – Glen_b Dec 22 '14 at 3:05
  • $\begingroup$ I'd have thought something like "Remapping variables to the unit interval" would be a more clear edit for the title, but I'll leave that to you; what you have now is an improvement. $\endgroup$ – Glen_b Dec 22 '14 at 3:07
1
$\begingroup$

If it's just a matter of doing the simulation, you can, in the normal case, do:

mu1 <- 0
mu2 <- 1

sd1 <- 1
sd2 <- 3

N <- 10^4

z <- rnorm(N, mean = mu1, sd = sd1) + rnorm(N, mean = mu2, sd = sd2)

x <- rbinom(N, size = 1, prob = exp(z)/(exp(z)+1))

For the lognormal:

u <- exp(z)

y <- rbinom(N, size = 1, prob = u/(u+1))

By the way, the title of the question is misleading. You're just changing the range of the random variables, you're not transforming them in a uniform random variable.

$\endgroup$
  • $\begingroup$ Sure! But there's no ground truth i.e. I can not verify if its the correct thing to do. For instance, there might be other ways of doing this transformation etc. $\endgroup$ – Blade Runner Dec 22 '14 at 2:32
  • 1
    $\begingroup$ There are infinitely many ways of doing the transformations. $\endgroup$ – Zen Dec 22 '14 at 2:34
-1
$\begingroup$

Let $X$ have the continuous cdf $F_X(x)$ then define the random variable $Y=F_X(x)$. Then $Y$ is uniformly distributed on $(0,1)$. This important property is called the Probability Integral Transform.

In your case, you may transform $Z$ and $LZ$ to uniformly distributed variables by using their respective cdf's. The first cdf is easy (Z is normally distributed), the last is more challenging (the sum of two log normals is not log normal).

Proof: $$P(Y\leq y) = P(F_X(X) \leq y)$$ $$=P(F_X^{-1}[F_X(X)] \leq F_X^{-1}(y))$$ $$=P(X \leq F_X^{-1}(y))$$ $$=F_X(F_X^{-1}(y))=y$$

At the end points we have $P(Y \leq y)=1$ for $y = 1$ and $P(Y \leq y)=0$ for $y = 0$ verifying that $Y$ has a uniform distribution.

$\endgroup$
  • $\begingroup$ The probability integral transform works in the opposite direction i.e. it transforms a uniform r.v to normal etc. $\endgroup$ – Blade Runner Dec 22 '14 at 2:34
  • 1
    $\begingroup$ The definition I am giving you comes out of the text "Statistical Inference" by G. Cassala and L. Berger which was my introductory graduate level text. It is similar to the definition given on Wikipedia en.wikipedia.org/wiki/Probability_integral_transform $\endgroup$ – Zachary Blumenfeld Dec 22 '14 at 2:40
  • 1
    $\begingroup$ Blade Runner - conventionally the probability integral transform is the term for applying F_X to X ... and $F_X(X)$ is uniform. See here. You're thinking of something else. Which is to say, Zachary is using the term in the sense that would be most widely understood. $\endgroup$ – Glen_b Dec 22 '14 at 3:16
  • $\begingroup$ @ZacharyBlumenfeld: you mean G. Casella and R. Berger as the authors of the book. $\endgroup$ – Xi'an Dec 22 '14 at 8:36

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.