factored out kernel density estimate