Skip to content

Commit

Permalink
Fix name
Browse files Browse the repository at this point in the history
  • Loading branch information
edeno committed Nov 7, 2017
1 parent f801ea6 commit 7214ae2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions replay_classification/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,15 @@ def empirical_movement_transition_matrix(place, place_bin_edges,
place_bin_edges),
normed=False)
smoothed_movement_bins_probability = gaussian_filter(
_normalize_column_probability(
_normalize_row_probability(
_fix_zero_bins(movement_bins)), sigma=0.5)
return np.linalg.matrix_power(
smoothed_movement_bins_probability,
sequence_compression_factor)


def _normalize_column_probability(x):
'''Ensure the state transition matrix columns integrate to 1
so that it is a probability distribution
def _normalize_row_probability(x):
'''Ensure the state transition matrix rows sum to 1
'''
return x / x.sum(axis=1, keepdims=True)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
from scipy.linalg import block_diag

from replay_classification.core import (_fix_zero_bins, _get_prior,
_normalize_column_probability,
_normalize_row_probability,
_update_posterior,
combined_likelihood,
get_bin_centers,
normalize_to_probability)


def test__normalize_column_probability():
'''All columns should sum to one after normalization
def test__normalize_row_probability():
'''All rows should sum to one after normalization
'''
transition_matrix = np.arange(1, 10).reshape(3, 3)
expected = np.ones((3,))
assert np.allclose(
_normalize_column_probability(transition_matrix).sum(axis=1),
_normalize_row_probability(transition_matrix).sum(axis=1),
expected)


Expand Down

0 comments on commit 7214ae2

Please sign in to comment.