Esempio n. 1
0
def makePatchStatsDict(patchDict, minpatchDataDict):
    zoneDict = minpatchDataDict["zoneDictionary"]
    patchStatsDictionary = {}
    allAreaList, validAreaList = makePatchAreaLists(patchDict, zoneDict)

    if len(allAreaList) > 0:
        medianAllPatch = stats.lmedianscore(allAreaList)
    else:
        medianAllPatch = 0

    if len(validAreaList) > 0:
        medianValidPatch = stats.lmedianscore(validAreaList)
    else:
        medianValidPatch = 0

    patchStatsDictionary["AllPatchCount"] = len(allAreaList)
    patchStatsDictionary["AllPatchArea"] = sum(allAreaList)
    patchStatsDictionary["medianAllPatch"] = medianAllPatch
    patchStatsDictionary["ValidPatchCount"] = len(validAreaList)
    patchStatsDictionary["ValidPatchArea"] = sum(validAreaList)
    patchStatsDictionary["medianValidPatch"] = medianValidPatch

    return patchStatsDictionary
Esempio n. 2
0
def makePatchStatsDict(patchDict, minpatchDataDict):
    zoneDict = minpatchDataDict["zoneDictionary"]
    patchStatsDictionary = {}
    allAreaList, validAreaList = makePatchAreaLists(patchDict, zoneDict)

    if len(allAreaList) > 0:
        medianAllPatch = stats.lmedianscore(allAreaList)
    else:
        medianAllPatch = 0

    if len(validAreaList) > 0:
        medianValidPatch = stats.lmedianscore(validAreaList)
    else:
        medianValidPatch = 0

    patchStatsDictionary["AllPatchCount"] = len(allAreaList)
    patchStatsDictionary["AllPatchArea"] = sum(allAreaList)
    patchStatsDictionary["medianAllPatch"] = medianAllPatch
    patchStatsDictionary["ValidPatchCount"] = len(validAreaList)
    patchStatsDictionary["ValidPatchArea"] = sum(validAreaList)
    patchStatsDictionary["medianValidPatch"] = medianValidPatch

    return patchStatsDictionary
Esempio n. 3
0
 def estimate(self,l):
     def sumvar(l,m):
         return stats.sum(map(lambda x:(x-m)**2,l))
     med=stats.lmedianscore(l)
     oldmed=med+1
     while med!=oldmed:
         l0=filter(lambda x: x<med,l)
         l1=filter(lambda x: x>med,l)
         lm=filter(lambda x: x==med,l)
         mu0=stats.mean(l0*2+lm)
         mu1=stats.mean(l1*2+lm)
         (oldmed,med)=(med,(mu0+mu1)/2)
         #print mu0,mu1, oldmed,med#,l0,l1
     self.sigma=max(0.1**10, math.sqrt((sumvar(l0+lm,mu0)+sumvar(l1,mu1)+(mu1-med)**2)/(len(l))))
     self.p0=(len(l0)+len(lm)*0.5)/len(l)
     self.p1=(len(l1)+len(lm)*0.5)/len(l)
     self.mu0=mu0
     self.mu1=mu1
     return self.mu0, self.mu1, self.sigma, self.p0, self.p1
Esempio n. 4
0
    def estimate(self, l):
        def sumvar(l, m):
            return stats.sum(map(lambda x: (x - m)**2, l))

        med = stats.lmedianscore(l)
        oldmed = med + 1
        while med != oldmed:
            l0 = filter(lambda x: x < med, l)
            l1 = filter(lambda x: x > med, l)
            lm = filter(lambda x: x == med, l)
            mu0 = stats.mean(l0 * 2 + lm)
            mu1 = stats.mean(l1 * 2 + lm)
            (oldmed, med) = (med, (mu0 + mu1) / 2)
            #print mu0,mu1, oldmed,med#,l0,l1
        self.sigma = max(
            0.1**10,
            math.sqrt((sumvar(l0 + lm, mu0) + sumvar(l1, mu1) +
                       (mu1 - med)**2) / (len(l))))
        self.p0 = (len(l0) + len(lm) * 0.5) / len(l)
        self.p1 = (len(l1) + len(lm) * 0.5) / len(l)
        self.mu0 = mu0
        self.mu1 = mu1
        return self.mu0, self.mu1, self.sigma, self.p0, self.p1