We use a Bayesian approach to derive the distance probability distribution for one object from its parallax with measurement uncertainty for two spatial distribution priors, viz. a homogeneous spherical distribution and a galactocentric distribution - applicable for radio pulsars - observed from Earth. We investigate the dependence on measurement uncertainty, and show that a parallax measurement can underestimate or overestimate the actual distance, depending on the spatial distribution prior. We derive the probability distributions for distance and luminosity combined, and for each separately, when a flux with measurement error for the object is also available, and demonstrate the necessity of and dependence on the luminosity function prior. We apply this to estimate the distance and the radio and gamma-ray luminosities of PSR J0218+4232. The use of realistic priors improves the quality of the estimates for distance and luminosity, compared to those based on measurement only. Use of a wrong prior, for example a homogeneous spatial distribution without upper bound, may lead to very wrong results.