<jupyter_start><jupyter_text>Conditional Distributions  To understand the relation between two variables you must examine the conditional behavior of each of them given the value of the other. Towards this goal, we will start by examining the simple example of the previous sections and then develop the general theory. In our example about heads in three tosses of a coin, where $X$ is the number of heads in the first two tosses and $Y$ the number of heads in the last two tosses, the joint distribution of $X$ and $Y$ and the two marginals are displayed in the table below.<jupyter_code>joint_dist.both_marginals()<jupyter_output><empty_output><jupyter_text>Given a particular value $x$ of $X$, that is, given that there were $x$ heads in the first two tosses, we can work out the *conditional distribution* of the number of heads in the last two tosses.In random variable language, for each value $x$ of $X$, the random variable $Y$ has a conditional distribution given $X = x$. We can get all three of these conditional distributions as follows:<jupyter_code># conditional distribution of Y given each different value of X

joint_dist.conditional_dist('Y', 'X')<jupyter_output>/home/choldgraf/anaconda/envs/dev/lib/python3.6/site-packages/prob140/multi_variable.py:208: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.
  matrix = y.as_matrix()[:-1, :]
{'fraction_non_alphanumeric': 0.06938483547925609, 'fraction_numerical': 0.006437768240343348, 'mean_word_length': 5.245535714285714, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '6842', 'license': 'MIT', 'n_tokens_mistral': 392, 'n_tokens_neox': 379, 'n_words': 191, 'path': 'notebooks/Chapter_04/03_Conditional_Distributions.ipynb', 'repo_name': 'choldgraf/prob140', 'size': '1398'}