There is great flexibility in the design of a digital filter. You can design digital filters that behave very similarly to analogue filters (as Andy aka described). You can also build digital filters than can be hard to reproduce in analogue such as a Linear phase filter or a Half-Band filter. Or non-linear digital filters such as Median filters that have no analogue equivalence in LTI systems.
For your requirements of "a sharp, low pass filter" I'd suggest a simple IIR of the form:
out = (1-a)in + aout
the closer 'a' is to 1 the lower the cutoff frequency of your filter.
You may well have a problem with the 1MHz sample rate and 5Hz cutoff because:
a = exp(-2*pi*f/fs)
where f is the cutoff frequency and fs is the sample frequency. So for your example:
a= exp(-2*pi*5/1E6) = 0.99997
If you really do need a 1MHz sample rate (because your data must be sampled by a 1MSPS ADC for example), then a 3 stage multi-rate filter is more appropriate. For this you would:
- Average 32 values at 1MHz and output one sample out of 32 at 1MHz/32
- Average 32 values at 1MHz/32 and output one sample out of 32 at 1MHz/32^2 (1MHz/1024)
- Implement an LPF as above with a 1MHz/1024 sample rate.
UPDATE BASED ON NEW INFO FROM OP:
Based on your information that:
- You are interested only in DC
- You are not sure about the cutoff frequency because you mention 60Hz and 6kHz bandwidth but also "A cutoff frequency of 5Hz"
- You need flexibility in sample rate
I think your best choice is a CIC Decimator.
Basically, its an MA (FIR) digital filter, made up of
- an integrator at the input clocked at the ADC sample rate (36kHz shown),
a differentiator at the output clocked at the output rate.
You can control how much filtering you get by changing the output rate.
For example with an input rate of 36kHz and an output rate of 5Hz this gives you a 36000/5 = 7200 point moving average. In reality you'd like to keep the rates as binary ratios so M=13 gives 36kHz in 36kHz/2^13 out and MA length is 2^M = 8192
The group delay of this will be 2^(M-1)/Fin or 113ms for the above example. That's one of the disadvantages of such a simple circuit but would not be a problem in a system whose DC value varies slowly.
The main reason that frequency-domain processing isn't done directly is the latency involved. In order to do, say, an FFT on a signal, you have to first record the entire time-domain signal, beginning to end, before you can convert it to frequency domain. Then you can do your processing, convert it back to time domain and play the result. Even if the two conversions and the signal processing in the middle are effectively instantaneous, you don't get the first result sample until the last input sample has been recorded. But you can get "ideal" frequency-domain results if you're willing to put up with this. For example, a 3-minute song recorded at 44100 samples/second would require you to do 8 million point transforms, but that's not a big deal on a modern CPU.
You might be tempted to break the time-domain signal into smaller, fixed-size blocks of data and process them individually, reducing the latency to the length of a block. However, this doesn't work because of "edge effects" — the samples at either end of a given block won't line up properly with the corresponding samples of the adjacent blocks, creating objectionable artifacts in the results.
This happens because of assumptions that are implicit in the process that converts between time domain and frequency domain (and vice-versa). For example, the FFT and IFFT "assume" that the data is cyclic; in other words, that blocks of identical time-domain data come before and after the block being processed. Since this is in general not true, you get the artifacts.
Time-domain processing may have its issues, but the fact that you can control the latency and it doesn't produce periodic artifacts make it a clear winner in most real-time signal-processing applications.
(This is an expanded version of my previous answer.)
Best Answer
First, note that FIR/IIR is not the same as non-recurrent/recurrent (where recurrent means that the output depends on previous inputs and previous outputs).
You can have a non-recurrent filter with infinite impulse response (e.g. \$h[n] = sinc(n/3)\$, which cannot be expressed as a recursion). And you can have a recursive construction for a FIR filter.
But, for finite-order systems, you can in general associate FIR with non-recursive forms, and IIR with recursive forms.
Your transfer function has a trivial denominator, so there is no recurrence. Divide by \$z^3\$ and you get:
$$H(z) = 0.1 + 0.5 z^{-1} + 0.3 z^{-2} + 0.1 z^{-3}$$
Trasnform back and you get the impulse response:
$$h[n] = 0.1 \delta[n] + 0.5 \delta[n-1] + 0.3 \delta[n-2] + 0.1 \delta[n-3]$$
The impulse response starts at \$n=0\$ and ends at \$n=3\$, therefore its support is finite (FIR).
If you had poles not at \$z=0\$, then you have an IIR filter. For example, if the denominator is \$\frac{\cdots}{z^2 (z-1/3)}\$, now you have a pole at \$z=1/3\$, and your recurrence equation yields (divide top and bottom by \$z^3\$ first):
$$Y(z)(1-1/3 z^{-1}) = X(z)(0.1 + 0.5 z^{-1} + 0.3 z^{-2} + 0.1 z^{-3})$$
$$y[n] - 1/3 y[n-1] = 0.1 x[n] + 0.5 x[n-1] + 0.3 x[n-2] + 0.1 x[n-3]$$
So you can see that the output \$y[n]\$ depends on previous inputs and also on the previous output \$y[n-1]\$.
Now to phase linearity:
Causal, finite-order digital filters can only be of generalized linear phase if the impulse response is symmetric (check these slides for the 4 types of symmetry; wikipedia article is undergoing copyright discussions).
So, for your original filter, the impulse response terms are
{ 0.1 0.5 0.3 0.1 }
; not symmetric, so not linear phase.IIR causal filters will never be linear phase (impulse response starts at 0 and never ends, so no symmetry possible).