def fisherTest(RSS1, RSS2, o1, o2, N): #print "Testing functions with parameters", o1, "and", o2, "with RSS", RSS1, "and", RSS2 #if (RSS1-RSS2)/(RSS2) < 0.125: return True #return (RSS1-RSS2)/RSS1 < (o2-o1)/o1 dof1 = N - o1 dof2 = N - o2 n1 = N - dof1 - 1 n2 = N - dof2 - 1 F = ((RSS1 - RSS2) / (n2 - n1)) / (RSS2 / (N - n2)) #F_dist = TF1("F_distr", "TMath::Sqrt( (TMath::Power([0]*x,[0]) * TMath::Power([1],[1])) / (TMath::Power([0]*x + [1],[0]+[1])) ) / (x*TMath::Beta([0]/2,[1]/2))", 0, 1000) #F_dist.SetParameter(0, n2-n1) #F_dist.SetParameter(1, N-n2) #CL = 1 - F_dist.Integral(0.00000001, F) CL = 1. - TMath.FDistI(F, n2 - n1, N - n2) #print F, N, n2-n1, N-n2, TMath.FDistI(F, n2-n1, N-n2) #print "F-test:", o1+1, "par vs", o2, "par & : F =", F, ", CL = %.4f" % CL return CL
def GetF21(rss1, rss2, n1, n2): Nbin = 28 ndof_parameter = Nbin - n2 f21 = (rss1 - rss2) / (n2 - n1) / (rss2 / (ndof_parameter)) CLF21 = 1. - (TMath.FDistI(f21, (n2 - n1), ndof_parameter)) return [f21, CLF21]