Inferring phenotypic evolution in the fossil record by Bayesian inversion