<commit_before>

      DOUBLE PRECISION FUNCTION combinationln(n,k)

c Ln of the number of different combinations of n different things, taken k at a time. 
c DH, 5.02.2007

      IMPLICIT NONE
      INTEGER n, k
      DOUBLE PRECISION factln

      combinationln= factln(n) - factln(k) - factln(n-k)

      END FUNCTION combinationln


      SUBROUTINE standardize(x, loc, scale, n, nloc, nscale, z)
      
c Compute z = (x-mu)/scale

cf2py double precision dimension(n), intent(in) :: x
cf2py double precision dimension(n), intent(out) :: z
cf2py double precision dimension(nloc), intent(in) :: loc
cf2py double precision dimension(nscale), intent(in) :: scale
cf2py integer intent(hide),depend(x) :: n=len(x)
cf2py integer intent(hide),depend(loc) :: nloc=len(loc)
cf2py integer intent(hide),depend(scale) :: nscale=len(scale)


      DOUBLE PRECISION x(n), loc(nloc), scale(nscale), z(n)
      DOUBLE PRECISION mu, sigma
      INTEGER n, nloc, nscale, i
      LOGICAL not_scalar_loc, not_scalar_scale
      
      mu = loc(1)
      sigma = scale(1)
      not_scalar_loc = (nloc .NE. 1)
      not_scalar_scale = (nscale .NE. 1)
      
      do i=1,n
        if (not_scalar_loc) mu = loc(i)     
        if (not_scalar_scale) sigma = scale(i)
        z(i) = (x(i) - mu)/sigma
      enddo
      END


      DOUBLE PRECISION FUNCTION gammln(xx) 
C Returns the value ln[gamma(xx)] for xx > 0. 

      DOUBLE PRECISION xx
      INTEGER j 
      DOUBLE PRECISION ser,stp,tmp,x,y,cof(6) 

C Internal arithmetic will be done in double precision, 
C a nicety that you can omit if five-figure accuracy is good enough. 

      SAVE cof,stp 
      DATA cof,stp/76.18009172947146d0,-86.50532032941677d0, 
     +24.01409824083091d0,-1.231739572450155d0,.1208650973866179d-2, 
     +-.5395239384953d-5,2.5066282746310005d0/ 
      x=xx
      y=x 
      tmp=x+5.5d0 
      tmp=(x+0.5d0)*dlog(tmp)-tmp 
      ser=1.000000000190015d0 
      do j=1,6
         y=y+1.d0 
         ser=ser+cof(j)/y 
      enddo 
      gammln=tmp+dlog(stp*ser/x) 
      return 
      END

      DOUBLE PRECISION FUNCTION factrl(n) 
C Returns the value n! as a floating-point number. 

      INTEGER n 

      INTEGER j,ntop 
C Table to be filled in only as required. 
      DOUBLE PRECISION a(33),gammln 
      SAVE ntop,a 
C Table initialized with 0! only. 
      DATA ntop,a(1)/0,1./

      if (n.lt.0) then 
        write (*,*) 'negative factorial in factrl' 
      else if (n.le.ntop) then 
C Already in table. 
        factrl=a(n+1) 
      else if (n.le.32) then 
C Fill in table up to desired value. <commit_msg>Added multivariate gamma function for use in Wishart likelihood.<commit_after>

      DOUBLE PRECISION FUNCTION combinationln(n,k)

c Ln of the number of different combinations of n different things, taken k at a time. 
c DH, 5.02.2007

      IMPLICIT NONE
      INTEGER n, k
      DOUBLE PRECISION factln

      combinationln= factln(n) - factln(k) - factln(n-k)

      END FUNCTION combinationln


      SUBROUTINE standardize(x, loc, scale, n, nloc, nscale, z)
      
c Compute z = (x-mu)/scale

cf2py double precision dimension(n), intent(in) :: x
cf2py double precision dimension(n), intent(out) :: z
cf2py double precision dimension(nloc), intent(in) :: loc
cf2py double precision dimension(nscale), intent(in) :: scale
cf2py integer intent(hide),depend(x) :: n=len(x)
cf2py integer intent(hide),depend(loc) :: nloc=len(loc)
cf2py integer intent(hide),depend(scale) :: nscale=len(scale)


      DOUBLE PRECISION x(n), loc(nloc), scale(nscale), z(n)
      DOUBLE PRECISION mu, sigma
      INTEGER n, nloc, nscale, i
      LOGICAL not_scalar_loc, not_scalar_scale
      
      mu = loc(1)
      sigma = scale(1)
      not_scalar_loc = (nloc .NE. 1)
      not_scalar_scale = (nscale .NE. 1)
      
      do i=1,n
        if (not_scalar_loc) mu = loc(i)     
        if (not_scalar_scale) sigma = scale(i)
        z(i) = (x(i) - mu)/sigma
      enddo
      END


      DOUBLE PRECISION FUNCTION gammln(xx) 
C Returns the value ln[gamma(xx)] for xx > 0. 

      DOUBLE PRECISION xx
      INTEGER j 
      DOUBLE PRECISION ser,stp,tmp,x,y,cof(6) 

C Internal arithmetic will be done in double precision, 
C a nicety that you can omit if five-figure accuracy is good enough. 

      SAVE cof,stp 
      DATA cof,stp/76.18009172947146d0,-86.50532032941677d0, 
     +24.01409824083091d0,-1.231739572450155d0,.1208650973866179d-2, 
     +-.5395239384953d-5,2.5066282746310005d0/ 
      x=xx
      y=x 
      tmp=x+5.5d0 
      tmp=(x+0.5d0)*dlog(tmp)-tmp 
      ser=1.000000000190015d0 
      do j=1,6
         y=y+1.d0 
         ser=ser+cof(j)/y 
      enddo 
      gammln=tmp+dlog(stp*ser/x) 
      return 
      END
      
      
      DOUBLE PRECISION FUNCTION mvgammln(x, k)
C Returns the logarithm of the multivariate gamma function for x > 0
      
      DOUBLE PRECISION PI
      PARAMETER (PI=3.141592653589793238462643d0)
      INTEGER j,k
      
      mvgammln = k * (k-1) / 4 * log(PI)
      
      do j=1,k
        mvgammln = mvgammln + gammln(x + (1-j)/2)
      enddo
      
      return
      END
      

      DOUBLE PRECISION FUNCTION factrl(n) 
C Returns the value n! as a floating-point number. 

      INTEGER n 

      INTEGER j,ntop 
C Table to be filled in only as required. 
      DOUBLE PRECISION a(33),gammln 
      SAVE ntop,a 
C Table initialized with 0! only. 
      DATA ntop,a(1)/0,1./

      if (n.lt.0) then 
        write (*,*) 'negative factorial in factrl' 
      else if (n.le.ntop) then 
C Already in table. 
        factrl=a(n+1) 
      else if (n.le.32) then 
C Fill in table up to desired value. 
{'fraction_non_alphanumeric': 0.09973285841495994, 'fraction_numerical': 0.06803205699020481, 'mean_word_length': 2.3995157384987893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2516556', 'n_tokens_mistral': 2390, 'n_tokens_neox': 2059, 'n_words': 570}