anchor.diff:            endif
             
             like = like + x(j,i)*dlog(p_tmp(i)) - factln(x(j,i))
  +          
  +          sumx = sumx + x(j,i)
  +          sump = sump + p_tmp(i)
   
           enddo
  +c This is to account for the kth term that is not passed!
  +        xk = n_tmp - sumx
  +        pk = 1.0 - sump
  +        if ((xk .LT. 0) .OR. (pk .LT. 0)) then
  +          like = -infinity
  +          RETURN
  +        endif
  +        like = like + (xk) * dlog(pk) 
  +        like = like - factln(xk)
  +        
           like = like + factln(n_tmp)
         enddo
         RETURN
  
positive.code:           RETURN
          endif
          
          do i=1,k
            if ((x(j,i) .LT. 0) .OR. (p_tmp(i) .LT. 1E-10)) then
              like = -infinity
  
negative.code: 
  c Multinomial log-likelihood function     
  c Updated 12/02/2007 DH. N-D still buggy.
  c Fixed 22/11/2007 CF
  
  cf2py integer dimension(nx,k),intent(in) :: x
  cf2py integer dimension(nn), intent(in) :: n
  