Пример #1
0
 def decision_function(A_SUCCESS, A_FAIL, B_SUCCESS, B_FAIL):
     decision_dict = {'DECISION': 'continue', 'ESTIMATED_DIFFERENCE': None}
     N_A = A_SUCCESS + A_FAIL
     N_B = B_SUCCESS + B_FAIL
     N_BOTH = N_A + N_B
     if N_BOTH % JUMP_ == 0 or N_BOTH >= MAX_TEST_SIZE:
         A_ALPHA_POST = ALPHA + A_SUCCESS
         A_BETA_POST = BETA + A_FAIL
         B_ALPHA_POST = B_PRIORS[0] + B_SUCCESS
         B_BETA_POST = B_PRIORS[1] + B_FAIL
         POSTERIOR = sample_posterior(A_ALPHA_POST, A_BETA_POST,
                                      B_ALPHA_POST, B_BETA_POST, N_A, N_B,
                                      HORIZON_LENGTH - N_BOTH, N_SAMPLES)
         LOSS_DIFF = POSTERIOR['LOSS_B'] - POSTERIOR['LOSS_A']
         if abs(LOSS_DIFF) > THRESHOLD or N_BOTH >= MAX_TEST_SIZE:
             decision_dict['ESTIMATED_DIFFERENCE'] = POSTERIOR['P_DIFF']
             if LOSS_DIFF > 0:  # Loss for B is greater than loss for A
                 decision_dict['DECISION'] = 'A'
             else:
                 decision_dict['DECISION'] = 'B'
     return decision_dict
Пример #2
0
 def decision_function(A_SUCCESS, A_FAIL, B_SUCCESS, B_FAIL):
     decision_dict = {
         'DECISION': 'continue',
         'ESTIMATED_DIFFERENCE': None
     }
     N_A = A_SUCCESS + A_FAIL
     N_B = B_SUCCESS + B_FAIL
     N_BOTH = N_A + N_B
     if N_BOTH % JUMP == 0 or N_BOTH > MAX_TEST_SIZE:
         A_ALPHA_POST = ALPHA + A_SUCCESS
         A_BETA_POST = BETA + A_FAIL
         B_ALPHA_POST = B_PRIORS[0] + B_SUCCESS
         B_BETA_POST = B_PRIORS[1] + B_FAIL
         POSTERIOR = sample_posterior(A_ALPHA_POST, A_BETA_POST,
                                      B_ALPHA_POST, B_BETA_POST, N_A,
                                      N_B, HORIZON_LENGTH - N_BOTH,
                                      N_SAMPLES)
         if HARD:
             if POSTERIOR['P_WIN'] > P_THRESHOLD_:
                 decision_dict['DECISION'] = 'B'
                 decision_dict['ESTIMATED_DIFFERENCE'] = POSTERIOR[
                     'P_DIFF']
             elif POSTERIOR['P_WIN'] < (
                     1 - P_THRESHOLD_) or N_BOTH >= MAX_TEST_SIZE:
                 decision_dict['DECISION'] = 'A'
                 decision_dict['ESTIMATED_DIFFERENCE'] = POSTERIOR[
                     'P_DIFF']
         else:
             if POSTERIOR['P_WIN'] > P_THRESHOLD_ or POSTERIOR[
                     'P_WIN'] < (
                         1 - P_THRESHOLD_) or N_BOTH >= MAX_TEST_SIZE:
                 decision_dict['ESTIMATED_DIFFERENCE'] = POSTERIOR[
                     'P_DIFF']
                 if POSTERIOR[
                         'P_WIN'] > 0.5:  # Loss for B is greater than loss for A
                     decision_dict['DECISION'] = 'B'
                 else:
                     decision_dict['DECISION'] = 'A'
     return decision_dict