How do you prevent drinking troughs from freezing ?

Electric heater or I've heard leaving a milk jug float in the water works too never done it though
You can leave something which floats on the surface (like straw, plastic bottle, balls ...)