Luis A. Afonso
Posts:
4,715
From:
LIsbon (Portugal)
Registered:
2/16/05


Re: An experiment . . . at random in intraPermutations
Posted:
Mar 6, 2013 9:50 AM


__0__Introduction
After several unsuccessful days with failed attempts I got an algorithm able to achieve the goal to find a Confidence Interval for the difference of two sample variances using the general intrapermutation noparametric method where the exhaustive noreplacement draws of the two source sample items are performed in order to construct the pseudosamples. __1__The Procedure Let X be a realworld sample, size nX, mean mX, whose items we randomly draw in order to form a pseudosample X´. After to to get it we have the current variance j given by: sdX(j)= (1<=i<=nX) Sum (X´(g)  mX)^2*Wx(i)/(nX1) where Wx(i) = i/(1+2+?+n), index showing the order the item is drawn: g=INT(nX*RND)+1. Once an item is chosen it is made unable to be redrawn in the current sample. Same operations for the sample Y, leading to d(j) as the generic member d(j) = sdX(j)  sdY(j).
__2__Illustrative example: the spider´s data (size 30) presented at my Feb 24, 2013 11:11 AM post.(see program below)
________Female _______________¬¬¬¬__Male__ ____sample mean= 8.127__________5.917___ ________std. dev.= 1.134__________0.663___ ______ Skewness = 1.0269 ________ 1.0181__ ___Exc. Kurtosis =1.9287________1.9512__
A 95% Confidence interval 20´000 iterations, provided [0.528, 1.165] for the difference of variances. So, one can conclude that at least the difference is 0.528, with 5% significance. Repeating with 1 million it was got an interval [0.525, 1.164]. As expected these intervals are centered at the source difference variances 0.846 approx. Luis A. Afonso REM "varSPID" REM CLS PRINT : PRINT "______VARSPID______"; PRINT " Spiderïs intraPermutation___variances" pi = 4 * ATN(1) DIM X(30), Y(30), xx(30), YY(30) DIM W(9000), wx(30), wy(30) INPUT " many= "; many REM male DATA 4.70,4.70,4.80,5.20,5.20,5.40,5.50,5.65,5.65,5.70 DATA 5.75,5.75,5.75,5.80,5.85,5.85,5.90,5.95,5.95,6.10 DATA 6.20,6.20,6.35,6.35,6.45,6.55,6.80,6.95,7.00,7.50 REM female DATA 5.90,6.10,6.30,6.60,7.00,7.05,7.05,7.50,7.55,7.55 DATA 7.80,7.95,8.00,8.00,8.10,8.25,8.30,8.30,8.35,8.45 DATA 8.70,8.75,9.00,9.10,9.30,9.50,9.60,9.80,9.95,10.00 REM n = 30 FOR i = 1 TO n: READ Y(i): YY(i) = Y(i) msY = msY + Y(i) / n: YY = YY + Y(i) * Y(i): NEXT i FOR i = 1 TO n: READ X(i): xx(i) = X(i) msX = msX + X(i) / n: xx = xx + X(i) * X(i): NEXT i varX = (xx  n * msX * msX) / (n  1) varY = (YY  n * msY * msY) / (n  1) PRINT "*** var female  var male > "; PRINT USING "#.### "; varX  varY REM FOR t = 1 TO 30: si = si + t: NEXT t FOR t = 1 TO 30: W(t) = t / si: NEXT t REM REM PRINT : COLOR 14 FOR tur = 1 TO many RANDOMIZE TIMER LOCATE 5, 55 PRINT USING "#########"; many  tur FOR i = 1 TO n: xx(i) = X(i): NEXT i FOR i = 1 TO n: YY(i) = Y(i): NEXT i REM gxx = 0 FOR t = 1 TO n 1 g = INT(n * RND) + 1 IF xx(g) = 123456 THEN GOTO 1 gxx = gxx + W(t) * (xx(g)  msX) * (xx(g)  msX) xx(g) = 123456 NEXT t gyy = 0 FOR t = 1 TO n 2 g = INT(n * RND) + 1 IF YY(g) = 123456 THEN GOTO 2 gyy = gyy + W(t) * (YY(g)  msY) * (YY(g)  msY) YY(g) = 123456 NEXT t varX = n * gxx / (n  1): REM gxx is a mean value varY = n * gyy / (n  1) d = varX  varY d1 = INT(1000 * d + .5) REM REM REM W(d1) = W(d1) + 1 NEXT tur REM COLOR 14 PRINT " Confidence Interval 95% " u(1) = .025: u(2) = 1  u(1) FOR uu = 1 TO 2 sum = 0 FOR gi = 0 TO 8000 sum = sum + W(gi) / many IF sum > u(uu) THEN GOTO 45 NEXT gi 45 PRINT USING "##.### .### "; gi / 1000; sum NEXT uu END

