  Probabilistic programming is a growing area that strives to make statistical
analysis more accessible, by separating probabilistic modelling from
probabilistic inference. In practice this decoupling is difficult. No single
inference algorithm can be used as a probabilistic programming back-end that is
simultaneously reliable, efficient, black-box, and general. Probabilistic
programming languages often choose a single algorithm to apply to a given
problem, thus inheriting its limitations. While substantial work has been done
both to formalise probabilistic programming and to improve efficiency of
inference, there has been little work that makes use of the available program
structure, by formally analysing it, to better utilise the underlying inference
algorithm.
  This dissertation presents three novel techniques (both static and dynamic),
which aim to improve probabilistic programming using program analysis. The
techniques analyse a probabilistic program and adapt it to make inference more
efficient, sometimes in a way that would have been tedious or impossible to do
by hand.
