Implementation of Ripley's K-function