A stochastic algorithm finding generalized means on compact manifolds