psifr.stats.rank_distance_shifted#

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

Calculate percentile rank of shifted distances.

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

  • max_shift (int) – Maximum number of items back for which to rank 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.

  • 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 – [transitions x max_shift] array with distance percentile ranks. 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:

numpy.ndarray

See also

rank_distance

to the immediately preceding item only.

Examples

>>> import numpy as np
>>> from psifr import stats
>>> distances = np.array(
...     [
...         [0, 1, 2, 2, 2],
...         [1, 0, 2, 2, 2],
...         [2, 2, 0, 3, 3],
...         [2, 2, 3, 0, 2],
...         [2, 2, 3, 2, 0],
...     ]
... )
>>> pool_items = [[1, 2, 3, 4, 5]]
>>> recall_items = [[4, 2, 3, 1]]
>>> pool_index = [[0, 1, 2, 3, 4]]
>>> recall_index = [[3, 1, 2, 0]]
>>> stats.rank_distance_shifted(
...     distances, 2, pool_items, recall_items, pool_index, recall_index
... )
array([[0.  , 0.25],
       [1.  , 1.  ]])