How to calculate the average price of a stock

What is the method to average out purchase prices of multiple stock lots?