Exemplo n.º 1
0
def alt_init(params, beliefs):
    alt0, alt1, worked0, worked1 = sm_wp_alternatives(beliefs)
    alt = [alt0, alt1]
    init = []
    alt_options = params['alt_options']
    for k in range(params['num_qs']):
        if k in worked0 and k in worked1:
            state = {}
            option = alt_options[k]
            state['world'] = option
            state['sm'] = alt[option][k][0]
            state['wp'] = alt[option][k][1]
            on = fwd.specify_own_noise(params['own_noise_hierarchy'],
                                       params['own_noise_default'],
                                       params['num_responses'])
            state['own_noise'] = on
            mn = fwd.specify_meta_noise(params['meta_noise_hierarchy'],
                                        params['meta_noise_type'],
                                        params['meta_noise_default'],
                                        params['num_responses'])
            state['meta_noise'] = mn
            state['expertise'] = np.zeros(params['num_responses'])
            init.append(state)
        else:
            init.append(aggregation_par.random_init_question(params))
    return init
def random_init_question(params):
    """Sample random state to initialise mcmc chain.
    Args: num-responses - num people answering questions.
    Outputs: dict
    """
    state = {}
    state['wp'], state['sm'] = fwd.sample_wp_sm(params['prior_wp_sm'])
    #state['world'] = fwd.sample_world(state['wp'])
    state['world'] = random.randint(0, 1)
    #state['signals'] = fwd.sample_signals(state['world'], state['sm'], 
    #                                      params['num_responses'])
    state['own_noise'] = fwd.specify_own_noise(params['own_noise_hierarchy'],
                                               params['own_noise_default'],
                                               params['num_responses'])
    state['meta_noise'] = fwd.specify_meta_noise(params['meta_noise_hierarchy'],
                                               params['meta_noise_type'],
                                               params['meta_noise_default'],
                                               params['num_responses'])
    state['expertise'] = np.zeros(params['num_responses'])
    return state