In this paper, a robot navigating an environment shared with humans is considered, and a cost function that can be exploited in $\text{RRT}^\text{X}$, a randomized sampling-based replanning algorithm that guarantees asymptotic optimality, to allow for a safe motion is proposed. The cost function is a path length weighted by a danger index based on a prediction of human motion performed using either a linear stochastic model, assuming constant longitudinal velocity and varying lateral velocity, and a GMM/GMR-based model, computed on an experimental dataset of human trajectories. The proposed approach is validated using a dataset of human trajectories collected in a real world setting.