How does a power regulator help "smooth out" a power supply?

I saw in an electronics book in a diagram that they had a capacitor running between the power rail and ground, with items plugged into those rails. How does the capacitor help out there, to "smooth things out"?

Thanks!

Capacitors reduce ripple in a DC line. They are a charge storage device, so when the voltage is dropping from a peak they help hold it up, when it is rising to a peak from a trough they charge drawing against the rising voltage. For DC filters, caps are usually very large values and size to provide the maximum sustaining charge and slow the rise to the peak.

In a transformer power supply large capacitor is needed to hold enough energy and charge between peaks in the mains supply (which occur at 100 or 120Hz).

In a modern switch-mode supply the input is chopped up at perhaps 20kHz and the storage capacitors only have to store energy across the mains zero-crossing for a much smaller proportion of the time.

The equation for an ideal capacitor is C dV = I dt (or put another way CV=Q where C is capacitance, Q is charge, dV is change in voltage, dt is a time interval.)

Say you want to provide 2A for 5ms whilest not letting the voltage drop more than 0.2V, you plug those figures into the first equation and get C = 50mF (= 50,000uF).

Further down the power supply chain capacitors serve to hold the voltage rail up on much shorter timescales, down to nanoseconds for the per-chip decoupling. At these timescales the self-inductance of the power wiring becomes more significant than its resistance, and placing a capacitor remote from the chip wouldn't work at all well.