psifr.stats.rank_distance#

psifr.stats.rank_distance(distances, pool_items, recall_items, pool_index, recall_index, pool_test=None, recall_test=None, test=None)#

Calculate percentile rank of transition distances.

Parameters:
  • distances (numpy.array) – Items x items matrix of pairwise distances or similarities.

  • 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.

  • recall_index (list of list) – Index of each recalled item.

  • 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.

Returns:

rank – Distance percentile rank for each included transition. The rank is 0 if the distance was the largest of the available transitions, and 1 if the distance was the smallest. Ties are assigned to the average percentile rank.

Return type:

list

See also

count_distance

Count transitions within distance bins.

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]])
>>> pool_items = [[1, 2, 3, 4]]
>>> recall_items = [[4, 2, 3, 1]]
>>> pool_index = [[0, 1, 2, 3]]
>>> recall_index = [[3, 1, 2, 0]]
>>> stats.rank_distance(
...     distances, pool_items, recall_items, pool_index, recall_index
... )
[0.75, 0.0, nan]