Stability analysis of swarms in a noisy environment