  We propose an efficient and model independent method for reconstructing the
primordial power spectrum from Cosmic Microwave Background (CMB) and large
scale structure observations. The algorithm is based on a Monte Carlo principle
and therefore very simple to incorporate into existing codes such as Markov
Chain Monte Carlo. The algorithm has been used on present cosmological data to
test for features in the primordial power spectrum. No significant evidence for
features is found, although there is a slight preference for an overall bending
of the spectrum, as well as a decrease in power at very large scales. We have
also tested the algorithm on mock high precision CMB data, calculated from
models with non-scale invariant primordial spectra. The algorithm efficiently
extracts the underlying spectrum, as well as the other cosmological parameters
in each case. Finally we have used the algorithm on a model where an artificial
glitch in the CMB spectrum has been imposed, like the ones seen in the WMAP
data. In this case it is found that, although the underlying cosmological
parameters can be extracted, the recovered power spectrum can show significant
spurious features, such as bending, even if the true spectrum is scale
invariant.
