Ejemplo n.º 1
0
def PLexMax(triple, K, threshold, numSteps, tempScale):
    for outG in triple.taxaSet:
        stepScale = tempScale
        branchData = triple.branches(outG)
        if len(branchData) < 2:
            continue
        cArray = list(np.zeros(K))
        pArray = [1. / K] * K
        lmbd = np.mean(branchData)
        for x in range(1, K):
            cArray[x] = x
        steps = 0
        while steps < numSteps:
            XQList = cyq.XQUpdate(branchData, cArray, pArray, lmbd)
            pArray = cyq.pUpdate(XQList)
            for indy in range(1, K):
                cArray[indy] = cyq.cSearch(branchData, XQList, indy, lmbd,
                                           cArray)
            storedlmbd = lmbd
            lmbd, stepScale = cyq.gradAscent(branchData, XQList, cArray,
                                             pArray, lmbd, stepScale, numSteps,
                                             threshold)
            cArray = [x * (storedlmbd / lmbd) for x in cArray]
            steps += 1
        triple.setModel(outG, list(cArray), list(pArray), lmbd)
        triple.setBIC(
            outG,
            np.log(len(branchData)) * (2 * K - 1) - 2 *
            (cyq.modelLogLik(branchData, list(cArray), list(pArray), lmbd)))
        triple.setNull(outG, oneDistNull(branchData))
    return triple
Ejemplo n.º 2
0
def oneDistNull(branchData):
    lmbd = np.mean(branchData)
    bic = np.log(len(branchData)) - 2 * (cyq.modelLogLik(
        branchData, [0.0], [1.0], lmbd))
    return (lmbd, bic)