# Path: Utility.py
# def l2(x):
# def apply_scale(w, a, b):
# def logabsdiffexp(x, y):
#     def f(x, y):
# def logit_mean(x):
# def digest(x):
# def tree():
# def lift_tree(src, dst):
# def init_latex_rendering():
# def draw_confidence(a, m, S, levels = [0.95]):


import numpy as np
from Utility import logsumexp
        return 0, 0

    C_alpha_l, C_alpha_u = C_alpha.min(), C_alpha.max()
    if C_alpha_l == theta_l_min:
        C_alpha_l = -np.inf
    if C_alpha_u == theta_l_max:
        C_alpha_u = np.inf

    return C_alpha_l, C_alpha_u

def ci_conservative_generic(X, K, theta_grid, alpha_level,
                            suff, log_likelihood, sample, t,
                            corrected = True, two_sided = True,
                            verbose = False):
    L = len(theta_grid)
    
    # Generate samples from the mixture proposal distribution
    Y = [sample(theta_grid[np.random.randint(L)]) for k in range(K)]

    # Test statistic at observation, for each grid point
    t_X = t(X).reshape((L, 1))
    if verbose:
        print 'X: t_min = %.2f, t_max = %.2f' % (t_X.min(), t_X.max())
        
    # Statistics for the samples from the proposal distribution only
    # need to be calculated once...
    t_Y = np.empty((L, K+1))
    t_Y[:,K] = 0.0
    for k in range(K):
        t_Y[:,k] = t(Y[k])

# Path: Utility.py
# def l2(x):
# def apply_scale(w, a, b):
# def logabsdiffexp(x, y):
#     def f(x, y):
# def logit_mean(x):
# def digest(x):
# def tree():
# def lift_tree(src, dst):
# def init_latex_rendering():
# def draw_confidence(a, m, S, levels = [0.95]):


# Path: Confidence.py
import numpy as np
from Utility import logsumexp

        return 0, 0

    C_alpha_l, C_alpha_u = C_alpha.min(), C_alpha.max()
    if C_alpha_l == theta_l_min:
        C_alpha_l = -np.inf
    if C_alpha_u == theta_l_max:
        C_alpha_u = np.inf

    return C_alpha_l, C_alpha_u

def ci_conservative_generic(X, K, theta_grid, alpha_level,
                            suff, log_likelihood, sample, t,
                            corrected = True, two_sided = True,
                            verbose = False):
    L = len(theta_grid)
    
    # Generate samples from the mixture proposal distribution
    Y = [sample(theta_grid[np.random.randint(L)]) for k in range(K)]

    # Test statistic at observation, for each grid point
    t_X = t(X).reshape((L, 1))
    if verbose:
        print 'X: t_min = %.2f, t_max = %.2f' % (t_X.min(), t_X.max())
        
    # Statistics for the samples from the proposal distribution only
    # need to be calculated once...
    t_Y = np.empty((L, K+1))
    t_Y[:,K] = 0.0
    for k in range(K):
        t_Y[:,k] = t(Y[k])

        if verbose: