Generalized Thompson Sampling for Sequential Decision-Making and Causal Inference