  We present a deterministic algorithm called contact density dynamics that
generates any prescribed target distribution in the physical phase space. Akin
to the famous model of Nos\'e-Hoover, our algorithm is based on a
non-Hamiltonian system in an extended phase space. However the equations of
motion in our case follow from contact geometry and we show that in general
they have a similar form to those of the so-called density dynamics algorithm.
As a prototypical example, we apply our algorithm to produce Gibbs canonical
distribution for a one-dimensional harmonic oscillator.
