Example #1
0
def groupTestExclusivity(events, bg):
    logP = numpy.log(bg)
    logNotP = numpy.log(1 - bg)
    pExactlyOne = numpy.exp(
        numpy.logaddexp.reduce(
            numpy.repeat(logNotP.sum(0)[numpy.newaxis], bg.shape[0], 0) +
            logP - logNotP, 0))
    x = numpy.sum(events.sum(0) == 1)

    return 1 - poisbinom.cdf(pExactlyOne, x - 1)
Example #2
0
def groupTestExclusivity(events, bg):
    logP = numpy.log(bg)
    logNotP = numpy.log(1 - bg)
    pExactlyOne = numpy.exp(
        numpy.logaddexp.reduce(
            numpy.repeat(logNotP.sum(0)[numpy.newaxis], bg.shape[0], 0) +
            logP - logNotP, 0))
    x = numpy.sum(events.sum(0) == 1)

    # the numpy.minimum(...) fix should probably be in the poisbinom
    # module rather than here, but it solves the problem for now
    return 1 - numpy.minimum(1.0, poisbinom.cdf(pExactlyOne, x - 1))
Example #3
0
def groupTestImpurity(events, bg):
    logP = numpy.log(bg)
    logNotP = numpy.log(1 - bg)
    pNone = numpy.exp(logNotP.sum(0)[numpy.newaxis])
    pExactlyOne = numpy.exp(
        numpy.logaddexp.reduce(
            numpy.repeat(logNotP.sum(0)[numpy.newaxis], bg.shape[0], 0) +
            logP - logNotP, 0))

    pMoreThanOne = 1 - pNone - pExactlyOne
    # Due to floating point precision issues the above probabilities
    # might end up being slightly smaller than 0; clip them at 0
    pMoreThanOne = numpy.maximum(0, pMoreThanOne)

    x = numpy.sum(events.sum(0) > 1)
    return poisbinom.cdf(pMoreThanOne, x)
Example #4
0
def groupTestCoverage(events, bg):
    pCovered = 1 - numpy.exp(numpy.log1p(-bg).sum(0))
    return 1 - poisbinom.cdf(pCovered, events.any(0).sum() - 1)