def logitProbitMixtureFunction(z, N, k, mu, sigma, isLogit): if isLogit == 1: density = util.logitDensity(z, mu, sigma) else: density = util.probitDensity(z, mu, sigma) probTerm = util.getBC(N, k) * (z**k) * ((1 - z)**(N - k)) f = probTerm * density return f
def independentBinomialAnalytic(N, p, c, alpha): pmfBinomial = np.zeros(N + 1) for k in range(0, N + 1): pmfBinomial[k] = util.getBC(N, k) * (p ** k) * ((1 - p) ** (N - k)) cdfBinomial = np.cumsum(pmfBinomial) varAnalytic = c * np.interp(alpha, cdfBinomial, np.linspace(0, N, N + 1)) esAnalytic = util.analyticExpectedShortfall(N, alpha, pmfBinomial, c) return pmfBinomial, cdfBinomial, varAnalytic, esAnalytic
def betaBinomialAnalytic(N, c, a, b, alpha): pmfBeta = np.zeros(N + 1) den = util.computeBeta(a, b) for k in range(0, N + 1): pmfBeta[k] = util.getBC(N, k) * util.computeBeta(a + k, b + N - k) / den cdfBeta = np.cumsum(pmfBeta) varAnalytic = c * np.interp(alpha, cdfBeta, np.linspace(0, N, N + 1)) esAnalytic = util.analyticExpectedShortfall(N, alpha, pmfBeta, c) return pmfBeta, cdfBeta, varAnalytic, esAnalytic
def getCMF_cr(s, myW, myA, myP, myN, myK): ps = myP * (1 - myW) + myP * myW * s f = util.getBC(myN, myK) * np.power(ps, myK) * np.power(1 - ps, myN - myK) return f * util.gammaDensity(s, myA, myA)
def getProdCMF(g, myRho, myP, myN, myK): pg = th.computeP(myP, myRho, g) return np.multiply(util.getBC(myN, myK), np.power(pg, myK) * np.power(1 - pg, myN - myK))
def getCMF(g, myRho, myP, myN, myK): pg = th.computeP(myP, myRho, g) f = util.getBC(myN, myK) * np.power(pg, myK) * np.power(1 - pg, myN - myK) cmf = f * util.gaussianDensity(g, 0, 1) return cmf
def bLikelihood(N, k, pDomain): L = util.getBC(N, k) * (pDomain ** k) * ((1 - pDomain) ** (N - k)) return L / np.abs(np.max(L))