The distributed generation (DG) has the characteristic of randomness which often results in the difference between the distributed generation actual output power and its planned value [1,2]. It is a popular method to introduce energy storage devices to compensate the difference so that to keep the power system in safe operation and qualified power quality. It is critical to determine the capacity of the energy storage device [3]. A statistic method is usually adopted to determine the capacity of the energy storage device, in which the capacity is gotten by analyzing the statistics data of the deviation between the predicted value and the actual value of distributed generation output power. But the existing method is not enough. it is necessary to verify the security of the system after determining the capacity. And the capacity also should be adjusted according to the verification. In fact the determining of the capacity is a optimization problem. Considering the characteristics of randomness, this paper introduces probabilistic power flow into the optimization model to find the proper size and location of the energy storage device. The model is described and a practical system is applied to verify the effectiveness and accuracy of the algorithm.