From stochastic environments to life histories and back