# Does data transformed in a certain way from a normal distribution fit some other common distribution?

I have sampled a number of $x$ values from a normal distribution with mean 0 and sd 0.2. I then transformed these $x$ values to $y$ values using the formula $y = e^x/(e^x + 1)$. I know that the $y$ values will have a mean of 0.5 and all lie between 0 and 1.

• Do these y values fit some common distribution?
• Is there a way to figure this out in R?

What I am looking for is if there is a simple distribution to describe the y values that would allow me to describe it in terms of a few parameters and possibly sample directly from it in R.

-
the distribution is given by a few parameter already with your definition ? what is the difference for the application you havde in mind, between sampling things directly and using a transfomation after sampling ? –  robin girard Oct 19 '10 at 6:20
To sample y, just sample x from a Normal(0, 0.2) distribution and compute y = e^x/(e^x+1). You can use (0, 0.2) as the parameters: by means of this formula they completely determine the distribution. –  whuber Oct 19 '10 at 16:25

You have:

$X \sim N(\mu,\sigma^2)$

By definition:

$Y = \frac{e^X}{e^X+1}$

Therefore, the cdf of $Y$ is:

$P(Y \le y) = P(\frac{e^X}{e^X+1} \le y)$

Simplifying the RHS, we get:

$P(Y \le y) = P(X \le -log(\frac{1-y}{y}) )$

Therefore,

$P(Y \le y) = \Phi(-log(\frac{1-y}{y}),\mu,\sigma^2)$

Differentiating the above wrt $y$, we get the pdf $f(y)$ as:

$f(y) = (\frac{1}{y(1-y)}) \phi(-log(\frac{1-y}{y}),\mu,\sigma^2)$

I do not think the above pdf has a standard name.

onestop identifies the correct name for the pdf in his answer: Logit-normal distribution.

Reg how to sample it in R you can use the inverse-transform sampling. The idea is as follows:

1. Generate a uniform random variate: $U \sim U[0,1]$

2. Set $U = \Phi(-log(\frac{1-y}{y}),\mu,\sigma^2)$ and invert for $y$.

However, the use of the inverse method sampling is not necessary as a you could just sample values of $Y$ by sampling from $X$ first and then doing the logistic transformation (as given in your question).

-

This is called a logit-normal distribution (by analogy with the much more common log-normal distribution). Knowing that doesn't simplify sampling from it, however, or change the parameters used to describe it, which are still the mean and SD (or variance) of the parent normal distribution.

-
Unless I'm misleading, the second moment are not exactly identical between the two. –  chl Oct 19 '10 at 7:18
@chi - I meant the usual parameterisation of the logit-normal is in terms of the mean and SD of the related normal dist, not that the mean and SD of the logit-normal are the same as that of the related normal. Sorry if that was, or still is, unclear - i'm editing in a hurry as i should really have left for work by now! –  onestop Oct 19 '10 at 7:29

The trivial way is just to realize this transformation and see what happens:

This looks pretty normal, indeed qqnorm confirms it:

-
Try the plots with a N(0,10^2) (i.e., 10 is standard deviation). It will not appear to be normal anymore. –  user28 Oct 19 '10 at 8:21
@Srikant I agree, this is an answer to second point of the question. –  mbq Oct 19 '10 at 9:14
You will run into trouble when you use any normal distribution with substantially nonzero mean. The logistic transformation is almost linear for values near zero but becomes strongly nonlinear for more extreme values. The resulting distribution will be strongly skewed; a normal approximation will be poor. This explains why your answer is effective for the particular distribution proposed by the OP (so I upvoted it and hope others do too) but also puts constraints on its generalization to similar looking problems. –  whuber Oct 19 '10 at 16:21
@whuber I agree, but I won't run into trouble, rather see that in such case it is not normal. This answer is just to promote trying as a technique, not to imply that resulting distribution will be always normal. –  mbq Oct 19 '10 at 16:40
Thank you for sharing your philosophy. I agree: it's good to help people learn to answer their own questions. Empirical investigation ("trying"), though, is usually best when informed by theoretical considerations to indicate the limits of its applicability. In this case you're safe with the Q-Q plot, because it is so sensitive to deviations from normality and you used a largish sample size of about a thousand, but the histogram alone can be deceiving. (Almost any bell-shaped histogram "looks" normal!) –  whuber Oct 19 '10 at 16:50