Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision a137ab8c6d6d0a8110a234da6f4de49aa7b548d9 authored by Roger Koenker on 31 August 2015, 23:25:56 UTC, committed by Gabor Csardi on 31 August 2015, 23:25:56 UTC
version 5.19
1 parent a6e1bd2
  • Files
  • Changes
  • 7636eae
  • /
  • src
  • /
  • akj.f
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:a137ab8c6d6d0a8110a234da6f4de49aa7b548d9
directory badge
swh:1:dir:a58012c164c314abf600da40546b4bba54a556df
content badge
swh:1:cnt:168636fb99a0f8008894aaf1be718170b9c16f9b

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
akj.f
C Output from Public domain Ratfor, version 1.01
      subroutine akj(x,z,p,iker,dens,psi,score,nx,nz,h,alpha,kappa,xlam)
C univariate kernel density-score estimator
C the algorithm is basically from Silverman as adapted for Portnoy and Koenker
C Annals paper on adaptive L-estimation in regression.
C x--pts used for centers of kernel assumed to be sorted!!!!
C z--pts at which density is calculated
C p--probability associated with x's
C dens--f(z), the densities at z
C psi--f'(z)/f(z) the score at z
C score--(log(f(z)))'', the J fn at z
C nx--number of pts in x
C nz--number of pts in z
C iker--kernel
C          0=gaussian
C	   1=cauchy
C h--initial window size (overall)--choose zero for default
C kappa--constant determining initial (default) window width
C xlam--Silverman's lambda, window adjustment for each x
      double precision dens(nz),score(nz),psi(nz),h,kappa
      double precision z(nz),x(nx),xlam(nx),p(nx),qrange,pi
      double precision con1,sum,sqsum,xsd,a,fifth,hinv,half
      double precision xn,xker,dxker,ddxker,fact,xponen,alpha,glog,zero,
     *     one,two
      parameter( zero = 0.d0)
      parameter( one = 1.d0)
      parameter( two = 2.d0)
      parameter( four = 4.d0)
      parameter( half = 0.5d0)
      parameter( fifth = 0.2d0)
      parameter( pi = 3.141593d0)

      xn=nx

C call srtad(x,1,nx) #port sort routine now done in S interface.

      if(iker.eq.0) then
         con1= one/sqrt(2.0*pi)
      else if(iker.eq.1) then
         con1= one/pi
      endif

C if no h is provided, calculate a default
      if(h.le.0.) then
         sum=0.
         sqsum=0.
         do 23006 i=1,nx
            sqsum=sqsum+x(i)*x(i)*p(i)
            sum=sum+x(i)*p(i)
23006    continue
         xsd=dsqrt(sqsum-sum*sum)
c     compute 'qrange' :=  IQR (x[i])

         sum=zero
c        first, qrange = Q_1 [ = quantile(*, 0.25) ]
         do i=1,nx
            sum=sum+p(i)
            if(sum .ge. .25) then
               qrange = x(i)
               goto 23010
            endif
         enddo
23010    continue
         sum=one
         do i=nx,1,-1
            sum=sum-p(i)
            if(sum .le. .75) then
               qrange = x(i) - qrange
               goto 23015
            endif
         enddo
23015    continue

         a=min(xsd,qrange/1.34)
         h=kappa*a/(xn**fifth)
C                             see Silverman p 48
      endif
      hinv=one/h

C Stage one:  compute pilot estimate of density
      do 23018 j=1,nx
         xker=0.
         if(iker.eq.0) then
            do 23022 i=1,nx
               xponen=(x(j)-x(i))*hinv
               xponen=half*xponen**2
               xker=xker+p(i)*exp(-xponen)*hinv
23022       continue
         else if(iker.eq.1) then
            do 23026 i=1,nx
               xponen=(x(j)-x(i))*hinv
               xker=xker+p(i)*hinv/(1+xponen**2)
23026       continue
         endif
         xlam(j)=con1*xker
23018 continue

C Stage two:  Automatic window widths (Silverman p101)
      glog=zero
      do 23028 i=1,nx
         glog=glog+p(i)*log(xlam(i))
23028 continue
      g=exp(glog)
      ginv=one/g
      do 23030 i=1,nx
         xlam(i)=hinv/((xlam(i)*ginv)**(-alpha))
C notice xlam no longer its own self at this pt! xlam is 1/(h*lambda(i))
C substitution of * for / thus achieved speeds things up
C Stage two:  new density-score estimates
23030 continue

      do 23032 j=1,nz
         xker=zero
         dxker=zero
         ddxker=zero
         if(iker.eq.0) then
C  gaussian kernel

            do 23036 i=1,nx
               xponen=(z(j)-x(i))*xlam(i)
               fact=exp(-half*xponen*xponen)*xlam(i)
               xker=xker+p(i)*fact
               dxker=dxker-p(i)*fact*xponen*xlam(i)
               ddxker=ddxker- p(i)*fact*(one - xponen**2)*xlam(i)**2
23036       continue

         else if(iker.eq.1) then
C   cauchy kernel

            do 23040 i=1,nx
               xponen=(z(j)-x(i))*xlam(i)
               fact=xlam(i)/(one+xponen**2)
               xker=xker+p(i)*fact
               dxker=dxker-p(i)*two*xponen*fact**2
               ddxker=ddxker- p(i)*two*(fact**2)*
     *              (xlam(i)- four*(xponen**2)*fact)
23040       continue
         endif
         dens(j)=con1*xker
         psi(j)=-(dxker/xker)
         score(j)=(dxker/xker)**2-ddxker/xker
23032 continue

      return
      end
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API