Correlation function in general and wavepacket with sharp number of photons