Test of ratio within population Let's say I have two large containers, X and Y, both containing a mix of red and blue buttons (for clothes). Consider the unknown ratios
$x$ := #blue / (#blue + #red) in container X
$y$ := #blue / (#blue + #red) in container Y.
I would like to know if $y > x$.
What I can do is take a handful of random buttons from each container and estimate $\bar{x}$ and $\bar{y}$ as the corresponding ratios in each handful.
What would be an appropriate statistical test to check $y > x$? 
Now suppose there is also a large number of green buttons in each container (the question remains verbatim). Can the same test be used? 
(This is something related to an interview question that I'd like to understand. Useful pointers and keywords appreciated. Thank you.)
 A: Here is output from Minitab's test comparing two proportions.
Suppose you took 39 buttons from Box A, of which 22 are red (for a sample proportion of $\hat p_1 = 0.564).$
and you took 37 buttons from Box B, of which 27 are red (for a sample proportion of $\hat p_2 = 0.730).$
These two sample proportions may seem quite different, but sample sizes are small, and such a difference might well have happened at random sampling from boxes with the same proportion of red buttons.
Specifically, the P-value is $0.132 > 0.05,$ so the sample proportions are not significantly different at the 5% level. This test, which uses a normal approximation, is explained on the NIST site.
Minitab's output also gives results of Fisher's exact test, which uses a hypergeometric distribution and also does not find a significant difference at the 5% level.
Test and CI for Two Proportions 

Sample   X   N  Sample p
1       22  39  0.564103
2       27  37  0.729730

Difference = p (1) - p (2)
Estimate for difference:  -0.165627
95% CI for difference:  (-0.377043, 0.0457882)
Test for difference = 0 (vs ≠ 0):  
   Z = -1.51  P-Value = 0.132

Fisher’s exact test: P-Value = 0.156

If you are not interested in green buttons, then completely ignore any green buttons
you happen to encounter.
Some details of the Fisher exact test are explained on several
pages on this site and on various Internet sites. Here is one of the
pages on this site. The relevant Wikipedia page (as it appears 15 Jul '19), is thorough and accurate,
but may tell you more than you want to know.
