  We have developed a unified finite-size scaling method for quantum phase
transitions that requires no prior knowledge of the dynamical exponent $z$.
During a quantum Monte Carlo simulation, the temperature is automatically tuned
by the Robbins-Monro stochastic approximation method, being proportional to the
lowest gap of the finite-size system. The dynamical exponent is estimated in a
straightforward way from the system-size dependence of the temperature. As a
demonstration of our novel method, the two-dimensional $S=1/2$ quantum $XY$
model in uniform and staggered magnetic fields is investigated in the
combination of the world-line quantum Monte Carlo worm algorithm. In the
absence of the uniform magnetic field, we obtain the fully consistent result
with the Lorentz invariance at the quantum critical point, $z=1$, i.e., the
three-dimensional classical $XY$ universality class. Under a finite uniform
magnetic field, on the other hand, the dynamical exponent becomes two, and the
mean-field universality with effective dimension $(2+2)$ governs the quantum
phase transition.
