Two methods for the determination of scatteringlength density profiles from specular reflectivity data are described. Both kinematical and dynamical theory can be used for calculating the reflectivity. In the first method, the scattering density is parameterized using cubic splines. The coefficients in the series are determined by constrained nonlinear least-squares methods, in which the smoothest solution that agrees with the data is chosen. The method is a further development of the two-step approach of Pedersen [J. Appl. Cryst. (1992), 25, 129-145-1. The second approach is based on a method introduced by Singh, Tirrell & Bates [J. Appl. Cryst. (1993), 26, 650-659] for analyzing reflectivity data from periodic profiles. In this approach, the profile is expressed as a series of sine and cosine terms. Several new features have been introduced in the method, of which the most important is the inclusion of a smoothness constraint, which reduces the coefficients of the higher harmonics in the Fourier series. This makes it possible to apply the method also to aperiodic profiles. For the analysis of neutron reflectivity data, the instrumental smearing of the model reflectivity is important and a method for fast calculation of smeared reflectivity curves is described. The two methods of analyzing reflectivity data have been applied to sets of simulated data based on examples from the literature, including an amphiphilic monolayer and block copolymer thin films. The two methods work equally well in most situations and are able to recover the original profiles. In general, the method using splines as the basis functions is better suited to aperiodic than to periodic structures, whereas the sine/cosine basis is well suited to periodic and nearly periodic structures.