The kth nearest neighbor method for estimation of entropy changes from molecular ensembles