Velocity fluctuation analysis via dynamic programming