Statistical theory of hysteresis in ferroelectric materials