Ejemplo n.º 1
0
def aggregateScores(node):
    relmap = common.relationMap(node)
    scores = {}
    totallen = sum(1 for n in relmap if n.ispublic)
    ibdsamples = {}
    for relative, relation in relmap.iteritems():
        if not relative.ispublic:
            continue
        h1, h2 = relation.keys()[0]
        if min(map(sum, relation.keys())) < 2:
            raise SiblingError
        ibdsample = ibdsamples[relative] = \
                        sampleFromPdfVector(cached.convolvedDensity(relation))
        if ibdsample == 0:
            continue
        for k, s in individualScores(node, relative, relation, ibdsample).iteritems():
            # total score is L-p norm
            scores.setdefault(k, []).append(s ** 0.5)
    return scores, ibdsamples
Ejemplo n.º 2
0
def individualScores(victim, relative, relation, sample):
    """sample is specified as an array index"""
    global _node, _rel
    pair = relation.keys()[0]
    nodeheight = pair[0]-pair[1]
    relmap = common.relationMap(relative, min(8, 9-nodeheight))
    if victim not in relmap:
        _node = victim
        _rel = relative
        assert False
    scores = {}
    for possiblevictim, relation in relmap.iteritems():
        h1, h2 = relation.keys()[0]
        if abs(h1 - h2) > 3 or min(map(sum, relation.keys())) < 2:
            continue
        pdfvector = cached.convolvedDensity(relation)
        scores[possiblevictim] = pdfvector[sample] if sample < len(pdfvector) else 0
    meanscore = utils.mean(scores.itervalues())
    maxscore = max(scores.itervalues())
    return dict(((k, val / maxscore) for k, val in scores.iteritems()))
Ejemplo n.º 3
0
def aggregateScores(node):
    relmap = common.relationMap(node)
    scores = {}
    totallen = sum(1 for n in relmap if n.ispublic)
    ibdsamples = {}
    for relative, relation in relmap.iteritems():
        if not relative.ispublic:
            continue
        h1, h2 = relation.keys()[0]
        if min(map(sum, relation.keys())) < 2:
            raise SiblingError
        ibdsample = ibdsamples[relative] = \
                        sampleFromPdfVector(cached.convolvedDensity(relation))
        if ibdsample == 0:
            continue
        for k, s in individualScores(node, relative, relation,
                                     ibdsample).iteritems():
            # total score is L-p norm
            scores.setdefault(k, []).append(s**0.5)
    return scores, ibdsamples
Ejemplo n.º 4
0
def individualScores(victim, relative, relation, sample):
    """sample is specified as an array index"""
    global _node, _rel
    pair = relation.keys()[0]
    nodeheight = pair[0] - pair[1]
    relmap = common.relationMap(relative, min(8, 9 - nodeheight))
    if victim not in relmap:
        _node = victim
        _rel = relative
        assert False
    scores = {}
    for possiblevictim, relation in relmap.iteritems():
        h1, h2 = relation.keys()[0]
        if abs(h1 - h2) > 3 or min(map(sum, relation.keys())) < 2:
            continue
        pdfvector = cached.convolvedDensity(relation)
        scores[possiblevictim] = pdfvector[sample] if sample < len(
            pdfvector) else 0
    meanscore = utils.mean(scores.itervalues())
    maxscore = max(scores.itervalues())
    return dict(((k, val / maxscore) for k, val in scores.iteritems()))
Ejemplo n.º 5
0
 def zeroProb(node):
     """prob that i.b.d. of node and cand is zero"""
     relation = common.relationMap(node).get(cand)
     return cached.convolvedDensity(relation)[0] if relation else 1.0
Ejemplo n.º 6
0
 def zeroProb(node):
     """prob that i.b.d. of node and cand is zero"""
     relation = common.relationMap(node).get(cand)
     return cached.convolvedDensity(relation)[0] if relation else 1.0