def _row_mask_to_nparams(mask):
    """
    @param mask: a boolean array
    """
    nparams = mask.sum() - 1
    if nparams < 0:
        msg = 'a stochastic vector cannot be all zeros'
        raise ValueError(msg)
    return nparams
