Example #1
0
def nellkForOptimization(vBetaAlpha, vBetaAlpha_old, c, y, xm, xr, m):
    """
    Wrapper of eval_logLikelihood.expectedLogLikelihood function, for being called in optimization.

    :param vBetaAlpha:
        1d numpy array.
        It is the vectorization of the two parameter matrices beta and alpha.
        For optimization, it will be given an initial value, which is the coefficient estimates from
        the previous step.
    :param vBetaAlpha_old:
        1d numpy array.
        It is the vectorization of the two parameter matrices, beta and alpha, estimated
        from the previous step.
    :param c:
        integer. Number of mixing components.
    :param y:
        numpy matrix. A column matrix containing the binomial responses
    :param xm:
        numpy matrix. Data matrix (after pre-processing) for modelling mixing probabilities.
    :param xr:
        numpy matrix, data matrix (after pre-processing) for modelling component probabilities.
    :param m:
        numpy matrix, a column matrix containing the number of trials for Binomial distribution,
        with size = y's size
    :return:
    """
    lxm = xm.shape[1]
    beta_old, alpha_old = mapOptimizationVector2Matrices(vBetaAlpha_old, c, lxm)
    beta, alpha = mapOptimizationVector2Matrices(vBetaAlpha, c, lxm)
    return -ellk(y, xm, xr, m, beta_old, alpha_old, beta, alpha)
Example #2
0
 def nollk(vBetaAlpha):
     """
     :param vBetaAlpha: 1d numpy array
     """
     lxm = xm.shape[1]
     beta, alpha = mapOptimizationVector2Matrices(vBetaAlpha, c, lxm)
     return  -ollk(y, xm, xr, m, beta, alpha)
Example #3
0
def nellkForOptimization_separate(vparams_old, c, y, xm, xr, m):
    lxm = xm.shape[1]
    lxr = xr.shape[1]
    beta_old, alpha_old = mapOptimizationVector2Matrices(vparams_old, c, lxm)

    q1, q2 = ellk_separate(y, xm, xr, m, beta_old, alpha_old)  # two callables

    def nq1(vbeta):
        beta = mapVector2Matrix(vbeta, lxm)
        return -q1(beta)

    def nq2(valpha):
        alpha = mapVector2Matrix(valpha, lxr)
        return -q2(alpha)

    return nq1, nq2