```
%matplotlib inline
```


```
import sympy
sympy.init_printing(use_latex=True)
```


```
from sympy.abc import x, y, alpha, beta
from sympy import latex
```


```
from IPython.display import HTML
```


```
def association_table(assocs):
    latexed = {}
    for key, value in assocs.items():
        latexed[key] = latex(value)
    latexed['s_total'] = latex(assocs['t_s'] + assocs['f_s'])
    latexed['ns_total'] = latex(assocs['t_ns'] + assocs['f_ns'])
    return """
    <TABLE>
    <TR><TH><TH>Significant<TH>Not significant
    <TR><TH>True association<TD>${t_s}$<TD>${t_ns}$
    <TR><TH>No association<TD>${f_s}$<TD>${f_ns}$
    <TR><TH>Total<TD>${s_total}$<TD>${ns_total}$
    </TABLE>
    """.format(**latexed)
```


```
assocs = dict(t_s = x,
              t_ns = alpha,
              f_s = beta,
              f_ns = y)
```


```
HTML(association_table(assocs))
```





<TABLE>
<TR><TH><TH>Significant<TH>Not significant
<TR><TH>True association<TD>$x$<TD>$\alpha$
<TR><TH>No association<TD>$\beta$<TD>$y$
<TR><TH>Total<TD>$\beta + x$<TD>$\alpha + y$
</TABLE>




639e4de36f745444000e03cfc5447e8b8a6413b7
ipynb
Jupyter Notebook
assoc_table.ipynb
matthew-brett/sketch-books
ed5afe08f2787880e70e30b023bc9fdf49338e3f
CC-BY-3.0
assoc_table.ipynb
matthew-brett/sketch-books
ed5afe08f2787880e70e30b023bc9fdf49338e3f
CC-BY-3.0
assoc_table.ipynb
matthew-brett/sketch-books
ed5afe08f2787880e70e30b023bc9fdf49338e3f
CC-BY-3.0
Qwen/Qwen-72B
1. YES
2. YES