      function bbi_df(n,k,p) ! bernd berg, october 24 1998.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      if(k.gt.n.or.n.le.0.or.k.lt.0) stop "bbi_df: false n or k."
      if(p.lt.zero .or. p.gt.one) stop "bbi_df: false p input."
c
      if(p.eq.zero) then
        bbi_df=one
      return
      end if
c
      if(p.eq.one) then
        bbi_df=zero
        if(k.eq.n) bbi_df=one
      return
      end if
c
      xkp1=one*(k+1)
      xnmk=one*(n-k)
      bbi_df=one-beta_i(p,xkp1,xnmk)
c
      return
      end
