Why is the Z very noisy around out of focus objects?
It seems the Z always gets only one sample, so it's always noisy around defocused objects regardless of the number of scene samples. However using the mist pass (which was added since that tutorial was made) instead of the Z gives a better result:



To define the distance/thickness of the mist, enable the mist display in the camera settings so that you can see a visualization in the 3D view:



Then adjust the start and depth of the mist in world settings: