added new function to compute truncated marginal over a window history instead of full history