From: <mli...@us...> - 2010-11-01 02:17:02
|
Revision: 31 http://salstat.svn.sourceforge.net/salstat/?rev=31&view=rev Author: mlivingstone Date: 2010-11-01 02:16:56 +0000 (Mon, 01 Nov 2010) Log Message: ----------- Fix regression I caused some time ago by non-Python space-delimited blocking aware editor Modified Paths: -------------- salstat_stats.py Modified: salstat_stats.py =================================================================== --- salstat_stats.py 2010-10-25 03:57:16 UTC (rev 30) +++ salstat_stats.py 2010-11-01 02:16:56 UTC (rev 31) @@ -68,7 +68,7 @@ itemp = ivec[j] ivec[j] = ivec[j+gap] ivec[j+gap] = itemp - gap = gap / 2 # integer division needed + gap = gap / 2 # integer division needed # svec is now sorted inlist, and ivec has the order svec[i] = vec[ivec[i]] return svec, ivec @@ -145,55 +145,55 @@ """ BIG = 20.0 def ex(x): - BIG = 20.0 - if x < -BIG: - return 0.0 - else: - return math.exp(x) + BIG = 20.0 + if x < -BIG: + return 0.0 + else: + return math.exp(x) - if chisq <=0 or df < 1: - return 1.0 + if chisq <= 0 or df < 1: + return 1.0 a = 0.5 * chisq if df%2 == 0: - even = 1 + even = 1 else: - even = 0 + even = 0 if df > 1: - y = ex(-a) + y = ex(-a) if even: - s = y + s = y else: - s = 2.0 * zprob(-math.sqrt(chisq)) + s = 2.0 * zprob(-math.sqrt(chisq)) if (df > 2): - chisq = 0.5 * (df - 1.0) - if even: - z = 1.0 - else: - z = 0.5 - if a > BIG: - if even: - e = 0.0 - else: - e = math.log(math.sqrt(math.pi)) - c = math.log(a) - while (z <= chisq): - e = math.log(z) + e - s = s + ex(c*z-a-e) - z = z + 1.0 - return s - else: - if even: - e = 1.0 - else: - e = 1.0 / math.sqrt(math.pi) / math.sqrt(a) - c = 0.0 - while (z <= chisq): - e = e * (a/float(z)) - c = c + e - z = z + 1.0 - return (c*y+s) + chisq = 0.5 * (df - 1.0) + if even: + z = 1.0 + else: + z = 0.5 + if a > BIG: + if even: + e = 0.0 + else: + e = math.log(math.sqrt(math.pi)) + c = math.log(a) + while (z <= chisq): + e = math.log(z) + e + s = s + ex(c*z-a-e) + z = z + 1.0 + return s + else: + if even: + e = 1.0 + else: + e = 1.0 / math.sqrt(math.pi) / math.sqrt(a) + c = 0.0 + while (z <= chisq): + e = e * (a/float(z)) + c = c + e + z = z + 1.0 + return (c*y+s) else: - return s + return s def inversechi(prob, df): """This function calculates the inverse of the chi square function. Given @@ -249,32 +249,32 @@ """ Z_MAX = 6.0 # maximum meaningful z-value if z == 0.0: - x = 0.0 + x = 0.0 else: - y = 0.5 * math.fabs(z) - if y >= (Z_MAX*0.5): - x = 1.0 - elif (y < 1.0): - w = y*y - x = ((((((((0.000124818987 * w - -0.001075204047) * w +0.005198775019) * w - -0.019198292004) * w +0.059054035642) * w - -0.151968751364) * w +0.319152932694) * w - -0.531923007300) * w +0.797884560593) * y * 2.0 - else: - y = y - 2.0 - x = (((((((((((((-0.000045255659 * y - +0.000152529290) * y -0.000019538132) * y - -0.000676904986) * y +0.001390604284) * y - -0.000794620820) * y -0.002034254874) * y - +0.006549791214) * y -0.010557625006) * y - +0.011630447319) * y -0.009279453341) * y - +0.005353579108) * y -0.002141268741) * y - +0.000535310849) * y +0.999936657524 + y = 0.5 * math.fabs(z) + if y >= (Z_MAX*0.5): + x = 1.0 + elif (y < 1.0): + w = y*y + x = ((((((((0.000124818987 * w + -0.001075204047) * w +0.005198775019) * w + -0.019198292004) * w +0.059054035642) * w + -0.151968751364) * w +0.319152932694) * w + -0.531923007300) * w +0.797884560593) * y * 2.0 + else: + y = y - 2.0 + x = (((((((((((((-0.000045255659 * y + +0.000152529290) * y -0.000019538132) * y + -0.000676904986) * y +0.001390604284) * y + -0.000794620820) * y -0.002034254874) * y + +0.006549791214) * y -0.010557625006) * y + +0.011630447319) * y -0.009279453341) * y + +0.005353579108) * y -0.002141268741) * y + +0.000535310849) * y +0.999936657524 if z > 0.0: - prob = ((x+1.0)*0.5) + prob = ((x+1.0)*0.5) else: - prob = ((1.0-x)*0.5) + prob = ((1.0-x)*0.5) return prob def ksprob(alam): @@ -289,12 +289,12 @@ termbf = 0.0 a2 = -2.0*alam*alam for j in range(1,201): - term = fac*math.exp(a2*j*j) - ksum = ksum + term - if math.fabs(term)<=(0.001*termbf) or math.fabs(term)<(1.0e-8*ksum): - return ksum - fac = -fac - termbf = math.fabs(term) + term = fac*math.exp(a2*j*j) + ksum = ksum + term + if math.fabs(term)<=(0.001*termbf) or math.fabs(term)<(1.0e-8*ksum): + return ksum + fac = -fac + termbf = math.fabs(term) return 1.0 # Get here only if fails to converge; was 0.0!! def fprob (dfnum, dfden, F): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |