Adaptive statistical algorithms for learning and control of neural dynamics