Rev 7899 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
c Part of R package KernSmoothc Copyright (C) 1995 M. P. Wandcc Unlimited use and distribution (see LICENCE).cccccccccc FORTRAN subroutine rlbin.f ccccccccccc Obtains bin counts for univariate regression datac via the linear binning strategy. If "trun=0" thenc weight from end observations is given to correspondingc end grid points. If "trun=1" then end observationsc are truncated.c Last changed: 26 MAR 2009subroutine rlbin(X,Y,n,a,b,M,trun,xcnts,ycnts)double precision X(*),Y(*),a,b,xcnts(*),ycnts(*),lxi,delta,reminteger n,M,i,li,trunc Initialize grid counts to zerodo i=1,Mxcnts(i) = dble(0)ycnts(i) = dble(0)end dodelta = (b-a)/(M-1)do i=1,nlxi = ((X(i)-a)/delta) + 1c Find integer part of "lxi"li = int(lxi)rem = lxi - lic Correction for right endpoint (not included if li.eq.M)if (X(i).eq.b) thenli = M - 1rem = 1endifif (li.ge.1.and.li.lt.M) thenxcnts(li) = xcnts(li) + (1-rem)xcnts(li+1) = xcnts(li+1) + remycnts(li) = ycnts(li) + (1-rem)*y(i)ycnts(li+1) = ycnts(li+1) + rem*y(i)endifif (li.lt.1.and.trun.eq.0) thenxcnts(1) = xcnts(1) + 1ycnts(1) = ycnts(1) + y(i)endifif (li.ge.M.and.trun.eq.0) thenxcnts(M) = xcnts(M) + 1ycnts(M) = ycnts(M) + y(i)endifend doreturnendcccccccccc End of rlbin.f cccccccccc