Skip to content

Instantly share code, notes, and snippets.

@gbushnell
Created October 1, 2020 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbushnell/142acb9c82b15b57616fbbd9470250df to your computer and use it in GitHub Desktop.
Save gbushnell/142acb9c82b15b57616fbbd9470250df to your computer and use it in GitHub Desktop.
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