Nanocrystalline CdS particles have been synthesized and dispersed in a polystyrene (PS) medium in the form of thin composite films. X-ray reflectivity and atomic force microscopy (AFM) have been used to study the films. CdS particles are found to precipitate towards the bottom of the films giving rise to a continuous change in the electron density along the depth of the film. It is shown that previous knowledge about the realistic model of electron density profile is required for correct interpretation of the X-ray reflectivity data for systems where electron density changes continuously and independent information obtained from atomic force microscopic studies can be used conveniently for this purpose.