initial code with the data and calculation of joint probabilities