Smoothed particle hydrodynamics (SPH) simulations are often initialized on a regular Cartesian grid. Ten SPH kernels were analyzed numerically with respect to their ability to correctly reproduce a uniform density distribution. Three types of kernels were identified. The number of neighboring particles required to represent the density with an accuracy of 0.1% was obtained for the 10 kernels in 1, 2 and 3 dimensions. The effect of random particle displacements from grid nodes on the error was investigated. The results of the study are important for correct application of initial conditions in SPH simulations.