%matplotlib inline

import chap01soln
resp = chap01soln.ReadFemResp()
resp.columns

"""
Explanation: Exercise from Think Stats, 2nd Edition (thinkstats2.com)<br>
Allen Downey
Read the female respondent file and display the variables names.
End of explanation
"""


import thinkstats2
hist = thinkstats2.Hist(resp.totincr)

"""
Explanation: Make a histogram of <tt>totincr</tt> the total income for the respondent's family.  To interpret the codes see the codebook.
End of explanation
"""


import thinkplot
thinkplot.Hist(hist, label='totincr')
thinkplot.Show()

"""
Explanation: Display the histogram.
End of explanation
"""


hist = thinkstats2.Hist(resp.ager)
thinkplot.Hist(hist, label='ager')
thinkplot.Show()

"""
Explanation: Make a histogram of <tt>age_r</tt>, the respondent's age at the time of interview.
End of explanation
"""


hist = thinkstats2.Hist(resp.numfmhh)
thinkplot.Hist(hist, label='humfmhh')
thinkplot.Show()

"""
Explanation: Make a histogram of <tt>numfmhh</tt>, the number of people in the respondent's household.
End of explanation
"""


hist = thinkstats2.Hist(resp.parity)
thinkplot.Hist(hist, label='parity')
thinkplot.Show()

"""
Explanation: Make a histogram of <tt>parity</tt>, the number of children born by the respondent.  How would you describe this distribution?
End of explanation
"""


hist.Largest(10)

"""
Explanation: Use Hist.Largest to find the largest values of <tt>parity</tt>.
End of explanation
"""


rich = resp[resp.totincr == 14]
hist = thinkstats2.Hist(rich.parity)
thinkplot.Hist(hist, label='parity')
thinkplot.Show()

"""
Explanation: Use <tt>totincr</tt> to select the respondents with the highest income.  Compute the distribution of <tt>parity</tt> for just the high income respondents.
End of explanation
"""


hist.Largest(10)

"""
Explanation: Find the largest parities for high income respondents.
End of explanation
"""


notrich = resp[resp.totincr < 14]
rich.parity.mean(), notrich.parity.mean()

"""
Explanation: Compare the mean <tt>parity</tt> for high income respondents and others.
End of explanation
"""


hist = thinkstats2.Hist(resp.fmarno)
thinkplot.Hist(hist, label='fmarno')
thinkplot.Show()

"""
Explanation: Investigate any other variables that look interesting.
End of explanation
"""


