updateP function

Update transition matrix