# Correct Specification of IPTW Estimator

As in this post, my understanding of the standard IPTW estimator is that it is $$\frac{1}{n} \sum_i \frac{Y_i T_i}{\hat{e}_i} - \frac{Y_i (1 -T_i)}{1 - \hat{e}_i}$$

This can straightforwardly be shown to unbiasedly estimate the Average Treatment Effect (ATE) when the propensity score model is correctly specified, as this paper does. However, in equation 2, section 2.3, that same paper specifies the IPTW estimator differently: $$\sum_i \frac{Y_i T_i}{\hat{e}_i} (\sum_i \frac{T_i}{\hat{e}_i})^{-1} - \sum_i \frac{Y_i (1 -T_i)}{1 -\hat{e}_i} (\sum_i \frac{1 - T_i}{1 - \hat{e}_i})^{-1}$$

I've run some simulations:

expit <- function(x) exp(x) / (1 + exp(x))

p <- 0.05
n <- 1e4
x <- cbind(rnorm(n), rexp(n), rbeta(n, 5, 5))
# t <- rbinom(n, 1, p)
t <- rbinom(n, 1, expit(x%*%c(-3,1,0)))
y <- 5*t + x%*%c(4,2,6) + rnorm(n)

prop <- glm(t ~ x[,1] + x[,2] + x[,3], family = binomial)
ps <- predict(prop, type = 'response')

iptw0 <- sum(y[t == 0] / (1 - ps[t == 0]))/n
iptw0
mean(y[t == 0])
weird0 <- sum(y[t == 0] / (1 - ps[t == 0]))/sum(1/(1 - ps[t == 0]))
weird0
iptw1 <- sum(y[t == 1] / ps[t == 1])/n
iptw1
mean(y[t == 1])
weird1 <- sum(y[t == 1] / ps[t == 1])/sum(1/ps[t == 1])
weird1

iptw1 - iptw0
weird1 - weird0


and both estimators appear to do perform well. Can anyone reconcile the two or provide references for the latter "weird" estimator?