Problems when fitting a reinforcement learning model to data

I can’t quite get your code to work. The call to tt.scan() is throwing an error, but I suspect that because I had to cobble a script together from your multiple posts. Would it be possible to provide a single, self-contained block of code that runs?