What is the optimal sampling split for stratified sampling? Suppose we have a population split into two strata of interest and we want to estimate the mean of some quantity of interest pertaining to the population.  Denote the quantities of interest for the two strata as $X_1,...,X_{N_X}$ and $Y_1,...,Y_{N_Y}$ so that the population mean is:
$$\bar{Q}_\text{pop} = \frac{\sum X_i + \sum Y_i}{N_X+N_Y}.$$
Assume that we know the population sizes $N_X$ and $N_Y$, so we know the proportion of people in each strata in the population.  Suppose we decide to undertake stratified sampling and we have resources to sample $n = n_X+n_Y$ people from the total population.  How do we decide the optimal split between the two strata?  Is there any simple "rule of thumb" for this sampling choice?
 A: In this analysis we will assume that we are making an inference about the population by forming the Welch-T confidence interval for the population mean, which is the standard interval estimator.  We will first set out the form of that interval estimator for the present problem and we will then show how we can "optimise" the sample allocation between the two groups to minimise the width of the confidence interval.  Under a simplifying assumption we discuss below, this leads to a fairly simple "rule of thumb" which we will discuss.

Interval estimator for the population mean under stratified sampling (with two groups): We have known population sizes $N_X$ and $N_Y$ for the respective strata, and we can denote the corresponding strata proportions by:
$$\lambda_X = \frac{N_X}{N_X + N_Y}
\quad \quad \quad \quad \quad 
\lambda_Y = \frac{N_Y}{N_X + N_Y}.$$
The inferential object of interest is the mean quantity over the whole population, which can be written as:
$$\bar{Q}_\text{pop} \equiv \frac{\sum_{i=1}^{N_X} X_{i} + \sum_{i=1}^{N_Y} Y_{i}}{N_X + N_Y}
= \lambda_X \bar{X}_P + \lambda_Y \bar{Y}_P.$$
Inference about this quantity can be undertaken by forming the Welch-t confidence interval, adjusted to account for finite population.  To do this, suppose we sample $n_X+n_Y = n$ values from the respective strata, and our observed data has sample means $\bar{x}$ and $\bar{y}$ and sample variances $s_X^2$ and $s_Y^2$.  The level $1-\alpha$ confidence interval for the population quantity is:
$$\text{CI}(1-\alpha) = \Bigg[ (\lambda_X \bar{x} + \lambda_Y \bar{y}) 
\pm t_{\alpha/2, DF} \sqrt{\Big( \frac{1}{n_X} - \frac{1}{N_X} \Big) \cdot \lambda_X^2 \cdot s_X^2 + \Big( \frac{1}{n_Y} - \frac{1}{N_Y} \Big) \cdot \lambda_Y^2 \cdot s_Y^2} \Bigg],$$
where we use the Welch-Satterwaite degrees-of-freedom:
$$DF = \frac{(n_X-1)(n_Y-1)}{(n_X-1) w_{XY}^2 + (n_Y-1) (1-w_{XY})^2}
\quad \quad \quad  
w_{XY} = \frac{\Big( \frac{1}{n_Y} - \frac{1}{N_Y} \Big) \cdot \lambda_Y^2 \cdot s_Y^2}{\Big( \frac{1}{n_X} - \frac{1}{N_X} \Big) \cdot \lambda_X^2 \cdot s_X^2 + \Big( \frac{1}{n_Y} - \frac{1}{N_Y} \Big) \cdot \lambda_Y^2 \cdot s_Y^2}.$$
This gives us the form of the confidence interval for the population mean, which is implicitly a function of the sample sizes $n_X$ and $n_Y$.  With a bit of algebra and calculus it can be shown that the function $DF(w_{XY})$ is a quasi-concave function with bounds $\min(n_X-1, n_Y-1) \leqslant DF(w_{XY}) \leqslant n_X + n_Y - 2$.  In the special case where we have infinite populations (i.e., we are making inferences about a mean parameter rather than the mean of a finite population) we have $1/N_X = 1/N_Y = 0$, which simplifies the above form of the functions.

Optimising the sample sizes: Accuracy of the inference can be measured using the half-width of the confidence interval:
$$\text{Half-length} \equiv t_{\alpha/2, DF(n_X,n_Y)} \sqrt{W(n_X,n_Y)},$$
where:
$$W(n_X,n_Y) \equiv \Big( \frac{1}{n_X} - \frac{1}{N_X} \Big) \cdot \lambda_X^2 \cdot s_X^2 + \Big( \frac{1}{n_Y} - \frac{1}{N_Y} \Big) \cdot \lambda_Y^2 \cdot s_Y^2.$$
It is a relatively simple computational problem to minimise the half-length function over all integer values $n_X$ and $n_Y$ satisfying the constraint $n_X + n_Y = n$, and this yields the post-hoc optimal sample sizes for stratified sampling.  The optimisation depends on the sample variances for the two samples, so a priori optimisation must occur under assumed variance values, which will generally differ from the observed values.
Exact optimisation of the above function is not particularly illuminating in an intuitive sense, but we can get a simple and illuminating "rule of thumb" if we approximate the optimisation by treating the degrees-of-freedom as if it were fixed (instead of a function of $n_X$ and $n_Y$).  Treating $DF$ as a fixed quantity means that $t_{\alpha/2, DF}$ is a fixed quantity, which means that minimisation of the half-length is equivalent to minimisation of $W(n_X,n_Y)$.  The Lagrangian for this constrained minimisation problem is:
$$\mathcal{L}(n_X,n_Y| \kappa) = \Big( \frac{1}{n_X} - \frac{1}{N_X} \Big) \cdot \lambda_X^2 \cdot s_X^2 + \Big( \frac{1}{n_Y} - \frac{1}{N_Y} \Big) \cdot \lambda_Y^2 \cdot s_Y^2 - \kappa (n - n_X - n_Y).$$
The Lagrangian is convex in $n_X, n_Y$, so the solution occurs at the critical point defined by:
$$\frac{\lambda_X^2 \cdot s_X^2}{\hat{n}_X^2} = \frac{\lambda_Y^2 \cdot s_Y^2}{\hat{n}_Y^2} = \kappa,$$
which gives the explicit solutions:
$$\hat{n}_X = \frac{\lambda_X \cdot s_X}{\lambda_X \cdot s_X + \lambda_Y \cdot s_Y} \cdot n
\quad \quad \quad \quad \quad 
\hat{n}_Y = \frac{\lambda_Y \cdot s_Y}{\lambda_X \cdot s_X + \lambda_Y \cdot s_Y} \cdot n.$$
This gives the "real" solution to the optimisation, and the integer solution should be nearby (i.e., one of the two integer pairs at either side of the real solution).  The equations for the optimal sample size can be written more succinctly in terms of proportionality as:
$$\boxed{\quad \\ \quad \hat{n}_X \propto \lambda_X \cdot s_X
\quad \quad \quad \quad \quad 
\hat{n}_Y \propto \lambda_Y \cdot s_Y \quad \\}$$
This gives us a simple "rule of thumb" which says that we should sample from both strata in a manner that is proportionate to their weight in the estimator times their sample standard deviation.  Consequently, strata having greater weight in the estimator (e.g., due to larger population size) should be given proportionately more weight in the sampling, and strata having greater sampling variability should have greater weight in the sampling.  Of course, this is a slight approximation, since exact optimisation also adjusts to take account of the variation in the degrees-of-freedom in the estimator under the chosen sampling scheme.  Nevertheless, the latter should generally be a small effect, so the rule of thumb gives quite a good approximation to optimal stratified sampling.
As an intuitive example of application of this principle, suppose we have a large population composed of equal numbers of males and females, and we want to know the average weight of the people in the population.  In such a case it is a reasonable a priori hypothesis that males will have larger variance in weight (since they are heavier on average).  We might decide that a reasonable a priori supposition is that males will have weight standard deviation that is 20% higher than females, in which case our "rule of thumb" would tell us to sample 6:5 males vs females in our stratified sampling.
