Inferring on the intentions of others by hierarchical Bayesian learning