psifr.stats.count_distance#
- psifr.stats.count_distance(distances, edges, pool_items, recall_items, pool_index, recall_index, pool_test=None, recall_test=None, test=None, count_unique=False)#
Count transitions within distance bins.
- Parameters:
distances (numpy.array) – Items x items matrix of pairwise distances or similarities.
edges (array-like) – Edges of bins to apply to distances.
pool_items (list of list) – Unique item codes for each item in the pool available for recall.
recall_items (list of list) – Unique item codes of recalled items.
pool_index (list of list) – Index of each item in the distances matrix.
pool_test (list of list, optional) – Test value for each item in the pool.
recall_test (list of list, optional) – Test value for each recalled item.
test (callable) – Called as test(prev, curr) or test(prev, poss) to screen actual and possible transitions, respectively.
count_unique (bool, optional) – If true, only unique values will be counted toward the possible transitions. If multiple items are avilable for recall for a given transition and a given bin, that bin will only be incremented once. If false, all possible transitions will add to the count.
- Returns:
actual (pandas.Series) – Count of actual transitions made for each bin.
possible (pandas.Series) – Count of possible transitions for each bin.
See also
rank_distance
Calculate percentile rank of transition distances.
Examples
>>> import numpy as np >>> from psifr import stats >>> distances = np.array([[0, 1, 2, 2], [1, 0, 2, 2], [2, 2, 0, 3], [2, 2, 3, 0]]) >>> edges = np.array([0.5, 1.5, 2.5, 3.5]) >>> pool_items = [[1, 2, 3, 4]] >>> recall_items = [[4, 2, 3, 1]] >>> pool_index = [[0, 1, 2, 3]] >>> recall_index = [[3, 1, 2, 0]] >>> actual, possible = stats.count_distance( ... distances, edges, pool_items, recall_items, pool_index, recall_index ... ) >>> actual (0.5, 1.5] 0 (1.5, 2.5] 3 (2.5, 3.5] 0 Name: count, dtype: int64 >>> possible (0.5, 1.5] 1 (1.5, 2.5] 4 (2.5, 3.5] 1 Name: count, dtype: int64