How to weight observations to transform a distribution into normal? Suppose X is a variable which follows some distribution (non normal) then how to define $f(X(k))$ (f is some functions of the variable X) such that
$$f(X)X$$ is normally distributed and $0\leq f(X(k))\leq1$ where $k$ shows observations. 
Thanks 
 A: I've been spending so much time coding lately that it took me a minute to dust-off my pencil-and-paper statistics to figure this out.
Basically, your need $f(X)$ to be the ratio between your target Gaussian and the value of the X, matched by quantile.  
You know the quantiles of any given gaussian ($G$) for the values of $X$ you observe: $F_G^{-1}(X) \equiv w$.  Just divide this by the value of $X$ to get their ratio.
I don't understand the constraint about the weights being between zero and 1.  I mean, you could divide the ratio by any number it make the weights smaller.  It'll just affect the standard deviation of the gaussian that you're normalizing to.
Here's a simple example:
Here's a random empirical distribution super-imposed on a gaussian:
x <- log(1:100)
x <- x-mean(x)
plot(ecdf(x), xlim = c(-4,4))
lines(ecdf(rnorm(10000)), col = "red")


For every point in $X$, you need the ratio between your target gaussian and $X$, matched by quantile.  Here's an example at the 95th quantile:
segments(x0 = qnorm(.95), x1 = quantile(x, .95), y0 = .95, col = "blue")


Basically, you divide the x position of the black line by the length of the blue line, for each point in your empirical distribution.  Note that you've got to trim the gaussian in practice given that your data is finite.
w = qnorm(grid[2:(length(grid)-1)])/x
plot(ecdf(rnorm(10000)))
lines(ecdf(x*w), col = "red")


And there you are!
A: Here's a non perfect solution. Imperfection comes from inability to guarantee that $f(X)\in[0,1]$.
Define, empirical CDF is $\hat F(X)\equiv \frac{rank(X)}{n+1}$, where $rank(x|X)\in[1,n]$ in the sample $X$ of $n$ observations.
Your $f(X)=\frac{\Phi^{-1}(\hat F(X);\hat\mu_X,\hat\sigma^2_X)}{X}$, where $\Phi$ is CDF of a normal distribution $\mathcal N(\hat\mu_X,\hat\sigma^2_X)$ with mean and variance of a sample $X$.
"Proof": $$s_i=f(x_i)x_i=\frac{\Phi^{-1}(\hat F(x_i))}{x_i}x_i
={\Phi^{-1}(\hat F(x_i))}$$
$S$ is from normal distribution because $\hat F(X)$ is from uniform distribution, then uniform fed into inverse CDF of normal returns normal. This is a basic fact of random variable transformations.
The only problem is that we cannot guarantee that $f(X)\in[0,1]$. By using sample estimators of mean and variance for $\Phi(x;\hat\mu_X,\hat\sigma^2_X)$ we increase the chance that $f(x)$ will have this property.
