Probabilistic derivation of wave equations