R/tauprob.R

Defines functions tauprob

Documented in tauprob

tauprob<-function(N,S){

IS<-abs(S)
M = N*(N-1)/2 - abs(IS)


IM <- trunc(M / 2 + 1)
L<-rep(0,IM*2)
dim(L)<-c(2,IM)

L[1,1] <- 1
L[2,1] <- 1
if (IM>=2)
	{
	for (I in (2:IM))
		{
		L[1,I] <- 0
      	L[2,I] <- 0
		}
	}
IL <- 1
I <- 1
M <- 1
J <- 1
JJ <- 2
while (I!=N)
	{
	IL <- IL + I
      I <- I + 1
      M <- M * I
      J <- 3 - J
      JJ <- 3 - JJ
      IN <- 1
      IO <- 0
      K <- min(IM,IL)
	stop10<-T
      while (stop10)
		{
		IN <- IN + 1
		if (IN>K) stop10<-F
	   	if (stop10)
			{
			L[JJ,IN] <- L[JJ,IN-1] + L[J,IN]
		      if (IN>I) 
				{
         			IO <- IO + 1
          			L[JJ,IN] <- L[JJ,IN] - L[J,IO]
				}
			}	
		}
	}
K <- 0
for (I in 1:IM) K <- K + L[JJ,I]
PRTAUS <- K/M
return(PRTAUS)
}

Try the rkt package in your browser

Any scripts or data that you put into this service are public.

rkt documentation built on Sept. 16, 2026, 5:07 p.m.