calculates probability,g(r)