Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Observed Frequencies
# Compute observed probability matrix
observed_prob_matrix = np.zeros((10, 2))
data_cols_length = [data.first_digit.count(), data[data.second_digit != 'NaN'].second_digit.count()]
for d_i in range(observed_prob_matrix.shape[0]):
for n_i in range(observed_prob_matrix.shape[1]):
observed_prob_matrix[d_i, n_i] = data[data.iloc[:, n_i + 2] == d_i].iloc[:, n_i + 2].count() / \
data_cols_length[n_i]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment