Abstract. The theta series $\vartheta(z)=\sum \exp(2\pi\i n^2 z)$ is a classical example of a modular form. In this talk we argue that the trace $\vartheta_P(z)=\Tr\, \exp(2\pi\i P^2 z)$, where $P$ is a first-order self-adjoint pseudo-differential operator with periodic bicharacteristic flow, may be viewed as a natural generalization. In particular, we establish approximate functional relations under the action of the modular group. This allows a detailed analysis of the asymptotics of $\vartheta_P(z)$ near the real axis, and the proof of logarithm laws and limit theorems for its value distribution.