scipy.stats.contingency.expected_freq¶
- scipy.stats.contingency.expected_freq(observed)[source]¶
Compute the expected frequencies from a contingency table.
Given an n-dimensional contingency table of observed frequencies, compute the expected frequencies for the table based on the marginal sums under the assumption that the groups associated with each dimension are independent.
- Parameters
- observedarray_like
The table of observed frequencies. (While this function can handle a 1-D array, that case is trivial. Generally observed is at least 2-D.)
- Returns
- expectedndarray of float64
The expected frequencies, based on the marginal sums of the table. Same shape as observed.
Examples
>>> from scipy.stats.contingency import expected_freq >>> observed = np.array([[10, 10, 20],[20, 20, 20]]) >>> expected_freq(observed) array([[ 12., 12., 16.], [ 18., 18., 24.]])