In statistics and machine learning, some models have loss functions of a form similar to that of the gravitational potential: a sum of kernel functions over all pairs of objects, where the kernel function depends on the distance between the objects in parameter space. Example problems that fit into this form include all-nearest-neighbors in manifold learning, kernel density estimation, and kernel machines. Alternative optimizations to reduce the O (n) time complexity to O (n) have been developed, such as dual tree algorithms, that have applicability to the gravitational n -body problem as well.