Statistical Physics of Data Assimilation and Machine Learning