How can gender and class classification be dependent? I got this question in my hw practice set 
In a class, there are 4 freshman boys, 6 freshman
girls, and 6 sophomore boys. How many sophomore
girls must be present if sex and class are to
be independent when a student is selected at random?
I solved the number (i believe is 9) that make class and gender independent. But it got me thinking: under what scenario, can class and gender be dependent? (i mean, class and gender are totally unrelated things right? therefore, they should be independent correct?) 
I tried cook up some numbers to show that they're dependent(see table below). Mathematically, I've shown, through the following table, that gender and classification are indeed dependent. But how can gender and class classification be dependent? 
            Male Female Total
Freshman     18    20    38
Sophomore    12    16    28          
Total        30    36    66

 A: One answer to "how can they be dependent" is simply that the number of sophomore girls is something other than $9$.  In particular, suppose all the sophomores were boys, whereas among freshmen there were some boys and some girls. Then the conditional probability that one of these is a boy, given that the person is a sophomore, would differ from the conditional probability that the person is a boy, given that he or she is a freshman.  So there's a lack of dependence.
Dependence and independence are here taken to mean dependence and independence only within this small group, not within any larger population from which one might suppose the small group to be a random sample.  Even if gender and class are independend in the population as a whole, one could get a small sample in which they are dependent.
Now suppose this were in a population among whom it is customary that those of one gender drop out of school after their freshman year.  There you'd have dependence.
A: This has a precise mathematical meaning. There are four "events": S=sophomore, F=freshman, G=girl, B=boy. All are parts of your "universe". You can construct new events, for instance F&G would mean the intersection of F and G, that is "freshman girls". Now you can compute the frequency of each event, say p(S&B) would be 6/N because there are 6 sophomore boys in a universe of N people (unfortunatelly N is unknown). 
Now, two events like "G=girl" and "F=freshman" are said to be "independent" if p(G&F) equals the product p(G).p(F) (why? later...)
Let us compute. If the number of sophomore girls is "x", the total population will be 4+6+6+x=16+x. So independence will imply 6/(16+x)=(6+x)/(16+x).10/(16+x). The solution is x=9 and you are right. Any other solution would mean that the events are not independent. Also you could check that the solution does not change when you try with p(G&S) and so on...
The notion of independence is cooked to obtain that the frequency of "freshman girls" (G&F) among "freshman people" (F), that is 6/10, or the frequency of G&S among S, that is 9/15, both equal the total frequency of girls in the universe, that is 15/25. The same thing with boys. If this happens, clearly "class" does not depend on "gender".
A: The only thing you can't do is have both some freshman girls and some sophomore boys in the mix.  They are dependent if you select one individual from your group, are told the class, and have more information about the gender.  So if you had three freshman girls and three sophomore boys, were told that a freshman was picked, you would know she was a girl.  Before being told the class, it was 50/50.  This is a dependent case.
If you have only sophomores, then being told the class doesn't help with the gender.  Similarly, being told the gender doesn't help with the class (which you already know).
If your group has both freshman girls and sophomore boys they are not indpendent.
