contingency_table#
- rojak.turbulence.metrics.contingency_table(x_var: DataArray, y_var: DataArray, *, sum_over: str | list[str] | None, z_var: DataArray | None = None) ContingencyTable[source]#
Contingency Table for multidimensional arrays
Computed contingency table as defined as,
\[\begin{split}\begin{array}{c|c|c|c} & Y = 1 & Y = 0 & \text{Total} \\ \hline X = 1 & n_{11} & n_{10} & n_{1\bullet} \\ X = 0 & n_{01} & n_{00} & n_{0\bullet} \\ \hline \text{Total} & n_{\bullet1} & n_{\bullet0} & n \end{array}\end{split}\]When :math`X` and :math`Y` are response variables, the probability of each case :math`pi_{ij}` is the joint distribution of :math`X` and :math`Y`, where :math`i` and :math`j` denotes the row and column respectively. When :math`Y` is the response variable and :math`X` is the explanation variable, then it conditional distribution of :math`Y` given :math`X`, is defined as,
\[\pi_{j | i} = \pi_{ij} / \pi_{i + } \quad \forall i \text{ and } j\]- Parameters:
x_var (DataArray) – First binary variable (:math`x` in contingency table)
y_var (DataArray) – Second binary variable (:math`y` in contingency table)
z_var (DataArray | None) – Optional third binary variable (:math`z` in contingency table) if x and y have a conditional association
sum_over (str | list[str] | None) – Dimension(s) to sum over to compute the number of observations. If None, it will sum over all dimension in the array
- Returns:
Instance of
ContingencyTable- Return type: