The duty cycle is just the ratio between the on-time duration (5V here) and T (T = 1/frequency). Multiply the ratio with 100 to get the duty cycle in percent.
For getting a smooth DC output, you need a low pass filter (for example RC filter) to average the output waveform. In other words that low pass filter removes the AC components.
DC output voltage = {V1*(duty cycle) + V0*(100-(duty cycle)) }/100
V1 is voltage corresponding to "1" V0 is voltage corresponding to "0", Duty Cycle in percentage.
The formula just calculates the average value of the waveform.
when the device/load/etc has averaging by itself, the low pass filter can be omitted. This is done frequently in electric motor controllers. The mass of the moving parts of the motor are acting as the low pass filter. There may be some filtering to avoid electromagnetic interference to (for example) radio equipment.