Ejemplo n.º 1
0
def test_get_mc0_precision():
    std_theta = 1
    var_epsilon = 1   
    n_students = 20
    n_classes = 10
    errors = np.zeros(n_classes)    
    precisions = np.zeros(n_classes)
    
    for class_ in range(n_classes):
        mu_1 = np.random.normal()
        mu_0 =  np.random.normal()

        df = construct_class_df(0, 0, n_students, std_theta, mu_0, mu_1, var_epsilon)
        
        collapsed = calculate_va_continuous.collapse(df)
        collapsed['m_c1'] = calculate_va_continuous.get_mc1(df)
        mc_0 = calculate_va_continuous.get_mc0(collapsed)
        
        errors[class_] = mc_0 - mu_0
        precisions[class_] = calculate_va_continuous.get_mc0_precision(std_theta**2, var_epsilon, df['continuous var'].values)
        
    check_calibration(errors, precisions)
Ejemplo n.º 2
0
def test_get_mc0():
    var_epsilon = abs(np.random.normal())
    std_theta = abs(np.random.normal())    
    n_students = 25
    n_classes = 1000

    errors = np.zeros(n_classes)    
    for class_ in range(n_classes):
        mu_1 = np.random.normal()
        mu_0 =  np.random.normal()
    
        df = construct_class_df(0, 0, n_students, std_theta, mu_0, mu_1, var_epsilon)
        df = calculate_va_continuous.collapse(df)
        df['m_c1'] = mu_1   # Just assume this is correctly estimated
        mc_0 = calculate_va_continuous.get_mc0(df)
        errors[class_] = mc_0 - mu_0
        
    error_se = (np.var(errors) / n_classes)**(.5)
    mean_error = np.mean(errors)

    assert mean_error > -2 * error_se
    assert mean_error < 2 * error_se