WSJT-X/lib/pctile.f90
Joe Taylor e6b515a9f1 Normalize the current and cumulative plots automatically.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2659 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2012-10-11 18:33:50 +00:00

26 lines
400 B
Fortran

subroutine pctile(x,npts,npct,xmedian)
real x(npts)
integer hist(0:1000)
ave=sum(x)/npts
hist=0
do i=1,npts
j=nint(100.0*x(i)/ave)
if(j.lt.0) j=0
if(j.gt.1000) j=1000
hist(j)=hist(j)+1
enddo
nsum=0
ntest=nint(npts*float(npct)/100.0)
do j=0,1000
nsum=nsum+hist(j)
if(nsum.ge.ntest) exit
enddo
xmedian=j*ave/100.0
return
end subroutine pctile