  We derive the initial spin period distribution of neutron stars by studying
the population of young pulsars associated with supernova remnants. Our
hierarchical Bayesian approach accounts for the measurement uncertainties of
individual observations and selection effects. Without correcting for selection
effects, as done in previous studies, we find that pulsar initial spin periods
follow a Weibull distribution, peaking at 40~ms, which is favoured against the
log-normal distribution with a Bayes factor of 200. The known selection effects
in radio pulsar surveys, including pulse broadening and a period-dependent
beaming fraction, have been quantitatively investigated. We show that, based on
measurements of pulsar luminosity and spin period from the ATNF Pulsar
Catalogue, the impact of pulse broadening on the inference of pulsar period
distribution is likely to be insignificant. Correcting for the beaming
selection effect, a Weibull distribution remains to be the preferred model,
while its peak slightly shifts to longer periods at 50~ms. Our method will
prove useful in constraining the birth properties of neutron stars in the
Square Kilometre Array era.
