Trajectory learning and analysis based on kernel density estimation