An analysis of the inversion distribution of a graded poset This can
be used to analyze the reference sequence against a sorted version of
itself or against permutations of these elements in a sequence passed in
(which may be graded or not). Note: When comparing two sequences, it
should be noted that these inversion measures are symmetric with respect
to which sequence is considered the reference versus the comparison.
Graded sequences are represented through nested lists, where each
subsequence contains the elements of a grade. So then, the sequence:
[[A,B,C], [1,2,3], [X,Y]] contains three grades, where A, B, and C have
rank 1, [1,2,3] have rank 2, etc. Elements that share a grade cannot
have inversions between them. The elements can be any valid Python
objects that have valid comparison operations (including custom class
instance). However, if any of the elements cannot be hashed, the
hashableElements flag must be set false or problems will occur.
Note: Technically, while this code refers to ``permutations'', two
sequences with the same elements but different grade structures are not
technically permutations (though two with the same grade structure,
regardless of structure, are certainly permutations). However, they are
VERY close to permutations and may be considered analogous to
permutations where you can't see the order of certain elements (i.e.,
censored observations).
|
__init__(self,
sequence,
isGraded=False,
hashableElements=True,
validate=False,
defaultGrade=None)
Initialize the reference sequence |
|
|
list of object or object
|
__iter__(self)
Iterate over the grades/elements |
|
|
int
|
__len__(self)
Get the number of grades in the sequence |
|
|
int or float
|
_calcGradedStatistic(self,
operation,
sequence=None,
isGraded=False)
Calculate a series length statistic, adjusting for incomparable
elements. |
|
|
List of list of object
|
_calcOverloadedRanks(self,
sequence,
isGraded,
otherSequence=None,
isOtherGraded=False)
Calculate the grades with more than one element (overloaded grades). |
|
|
list of list of object
|
_calcRankIntersections(self,
overloadedRanks,
overloadedRanks2)
Calculate the intersection of overloaded ranks between sequences. |
|
|
float
|
_comparisonTest(self,
test,
sequences,
sequences2=None,
isGraded=False,
measure=' similarity ' ,
**kwds)
Perform a hypothesis test on either the similarity or the complements
of the CDF values, which are a measure of the match between the each
sequence and the reference seq. |
|
|
int
|
_getElementIndex(self,
element,
sequence,
isGraded=False)
Get the index of the given value in the sequence Note: This hashes
element indices, if possible |
|
|
|
|
float
|
cdf(self,
sequence=None,
isGraded=False,
cdfType=' adaptive ' )
Calculate a CDF value for inversions between the reference sequence
abd a comparison sequence. |
|
|
float
|
correlation(self,
sequence=None,
isGraded=False)
The correlation of the reference sequence to a comparison sequence. |
|
|
float
|
exactCDF(self,
sequence=None,
isGraded=False)
Calculate an exact CDF value for inversions between the reference
sequence abd a comparison sequence. |
|
|
int
|
|
list of list of object
|
|
int
|
inversions(self,
sequence=None,
isGraded=False)
The inversions between the reference sequence and the comparison
sequence. |
|
|
|
isGraded(self)
Return if this is a graded poset. |
|
|
list of object or object
|
iterElements(self)
Iterate over the elements (flat iteration over grades) |
|
|
int
|
maxInversions(self,
sequence=None,
isGraded=False)
The maximum possible inversions, given the number of elements and the
number sharing each grade (e.g. |
|
|
int
|
mean(self,
sequence=None,
isGraded=False)
The mean of inversion across permutations, given the number of
elements and the number sharing each grade (e.g. |
|
|
float
|
normalCDF(self,
sequence=None,
isGraded=False)
Calculate an approximate CDF value for inversions between the
reference sequence abd a comparison sequence. |
|
|
float
|
permutationMeanTest(self,
sequences,
sequences2,
isGraded=False,
measure=' adaptive ' ,
alternative=' greater ' ,
pValue=0.95,
iterations=100000,
useStoppingRule=True,
maxExactN=7)
Perform a Permutation or Monte Carlo Mean Difference test on some
measure (similarity or 1-CDF) for the match between the each sequence
and the reference seq. |
|
|
float
|
permutationRankTest(self,
sequences,
sequences2,
isGraded=False,
measure=' adaptive ' ,
alternative=' greater ' ,
pValue=0.95,
iterations=100000,
useStoppingRule=True,
maxExactN=7)
Perform a Permutation or Monte Carlo rank test on a measure
(similarity or 1-CDF) for the match between the each sequence and the
reference seq. |
|
|
float
|
signTest(self,
sequences,
sequences2=None,
isGraded=False,
measure=' similarity ' ,
mu=0.5,
alternative=' greater ' )
Perform a Sign test on either the similarity or the complements of
the CDF values, which are a measure of the match between the each
sequence and the reference seq. |
|
|
float
|
similarity(self,
sequence=None,
isGraded=False)
The similarity of the reference sequence to a comparison sequence. |
|
|
int
|
stdDev(self,
sequence=None,
isGraded=False)
The standard deviation of inversions across permutations, given the
elements and the number sharing each grade (e.g. |
|
|
|
validate(self)
Check that this sequence is valid, so that it has no repeated
elements, that elements are hashable if sequence is hashable, and
that a graded sequence contains iterated grades. |
|
|
int
|
variance(self,
sequence=None,
isGraded=False)
The variance of inversions across permutations, given the number of
elements and the number sharing each grade (e.g. |
|
|
float
|
wilcoxonTest(self,
sequences,
sequences2=None,
isGraded=False,
cdfType=' adaptive ' ,
alternative=' greater ' )
Perform a Wilcoxon Rank Sum test on the complements of the CDF
values, which are a measure of the match between the each sequence
and the reference seq Mu cannot be set on this test, as it would
violate the assumption of symmetry. |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|