implement likelihood function