  It is a common practice to evaluate probability density function or matter
spatial density function from statistical samples. Kernel density estimation is
a frequently used method, but to select an optimal bandwidth of kernel
estimation, which is completely based on data samples, is a long-term issue
that has not been well settled so far. There exist analytic formulae of optimal
kernel bandwidth, but they cannot be applied directly to data samples, since
they depend on the unknown underlying density functions from which the samples
are drawn. In this work, we devise an approach to pick out the totally
data-based optimal bandwidth. First, we derive correction formulae for the
analytic formulae of optimal bandwidth to compute the roughness of the sample's
density function. Then substitute the correction formulae into the analytic
formulae for optimal bandwidth, and through iteration, we obtain the sample's
optimal bandwidth. Compared with analytic formulae, our approach gives very
good results, with relative differences from the analytic formulae being only
2%-3% for a sample size larger than 10^4. This approach can also be generalized
easily to cases of variable kernel estimations.
