Esempio n. 1
0
def calc(z, w, n, z2ss, start, stop):
    pid = mp.current_process()._identity[0]
    shared_sim = np.frombuffer(c_perm)
    for i in range(start, start + stop):
        r_num = np.random.RandomState(pid + i)
        z = r_num.permutation(z)
        zl = slag(w, z)
        inum = sum(z * zl)
        shared_sim[i] = n / w.s0 * inum / z2ss
Esempio n. 2
0
def calc(z,w,n,z2ss,start,stop):
    pid=mp.current_process()._identity[0]
    shared_sim = np.frombuffer(c_perm)
    for i in range(start,start+stop):
        r_num = np.random.RandomState(pid + i)
        z = r_num.permutation(z)
        zl = slag(w, z)
        inum = sum(z * zl)
        shared_sim[i] =  n / w.s0 * inum / z2ss
Esempio n. 3
0
 def __quads(self):
     zl = slag(self.w, self.z)
     zp = self.z > 0
     lp = zl > 0
     pp = zp * lp
     np = (1 - zp) * lp
     nn = (1 - zp) * (1 - lp)
     pn = zp * (1 - lp)
     self.q = self.quads[0] * pp + self.quads[1] * np + self.quads[2] * nn + self.quads[3] * pn
def quads(w,z):
    zl = slag(w,z)
    zp = z > 0
    lp = zl > 0
    pp = zp * lp
    np = (1 - zp) * lp
    nn = (1 - zp) * (1 - lp)
    pn = zp * (1 - lp)
    return 1 * pp + 2 * np + 3 * nn + 4 * pn
Esempio n. 5
0
 def __quads(self):
     zl = slag(self.w, self.z)
     zp = self.z > 0
     lp = zl > 0
     pp = zp * lp
     np = (1 - zp) * lp
     nn = (1 - zp) * (1 - lp)
     pn = zp * (1 - lp)
     self.q = 1 * pp + 2 * np + 3 * nn + 4 * pn
Esempio n. 6
0
 def __quads(self):
     zl = slag(self.w, self.z)
     zp = self.z > 0
     lp = zl > 0
     pp = zp * lp
     np = (1 - zp) * lp
     nn = (1 - zp) * (1 - lp)
     pn = zp * (1 - lp)
     self.q = self.quads[0] * pp + self.quads[1] * np + self.quads[
         2] * nn + self.quads[3] * pn
Esempio n. 7
0
    def calc(self):
        y = self.y
        y2 = y * y
        self.y_sum = y_sum = sum(y)
        y2_sum = sum(y2)

        if not self.star:
            yl = 1.0 * slag(self.w, y)
            ydi = y_sum - y
            self.Gs = yl / ydi
            N = self.n - 1
            yl_mean = ydi / N
            s2 = (y2_sum - y2) / N - (yl_mean)**2
        else:
            self.w.transform = 'B'
            yl = 1.0 * slag(self.w, y)
            yl += y
            if self.w_transform == 'r':
                yl = yl / (self.__getCardinalities() + 1.0)
            self.Gs = yl / y_sum
            N = self.n
            yl_mean = y.mean()
            s2 = y.var()

        EGs_num, VGs_num = 1.0, 1.0
        if self.w_transform == 'b':
            W = self.__getCardinalities()
            W += self.star
            EGs_num = W * 1.0
            VGs_num = (W * (1.0 * N - W)) / (1.0 * N - 1)

        self.EGs = (EGs_num * 1.0) / N
        self.VGs = (VGs_num) * (1.0 / (N**2)) * ((s2 * 1.0) / (yl_mean**2))
        self.Zs = (self.Gs - self.EGs) / np.sqrt(self.VGs)

        self.w.transform = self.w_original
Esempio n. 8
0
    def calc(self):
        y = self.y
        y2 = y * y
        self.y_sum = y_sum = sum(y)
        y2_sum = sum(y2)

        if not self.star:
            yl = 1.0 * slag(self.w, y)
            ydi = y_sum - y
            self.Gs = yl / ydi
            N = self.n - 1
            yl_mean = ydi / N
            s2 = (y2_sum - y2) / N - (yl_mean) ** 2
        else:
            self.w.transform = 'B'
            yl = 1.0 * slag(self.w, y)
            yl += y
            if self.w_transform == 'r':
                yl = yl / (self.__getCardinalities() + 1.0)
            self.Gs = yl / y_sum
            N = self.n
            yl_mean = y.mean()
            s2 = y.var()

        EGs_num, VGs_num = 1.0, 1.0
        if self.w_transform == 'b':
            W = self.__getCardinalities()
            W += self.star
            EGs_num = W * 1.0
            VGs_num = (W * (1.0 * N - W)) / (1.0 * N - 1)

        self.EGs = (EGs_num * 1.0) / N
        self.VGs = (VGs_num) * (1.0 / (N ** 2)) * ((s2 * 1.0) / (yl_mean ** 2))
        self.Zs = (self.Gs - self.EGs) / np.sqrt(self.VGs)

        self.w.transform = self.w_original
Esempio n. 9
0
 def calc(self, w, z):
     zl = slag(w, z)
     return self.n_1 * self.z * zl / self.den
Esempio n. 10
0
 def __calc(self, zy):
     wzy = slag(self.w, zy)
     self.num = sum(self.zx * wzy)
     self.den = sum(zy * zy)
     return self.num / self.den
Esempio n. 11
0
 def __calc(self, z):
     zl = slag(self.w, z)
     inum = sum(z * zl)
     return self.n / self.w.s0 * inum / self.z2ss
Esempio n. 12
0
 def calc(self, w, z):
     zl = slag(w, z)
     return self.n_1 * self.z * zl / self.den
Esempio n. 13
0
 def __calc(self, z):
     zl = slag(self.w, z)
     inum = (z * zl).sum()
     return self.n / self.w.s0 * inum / self.z2ss
Esempio n. 14
0
def _calc(z,w,n,z2ss):
    zl = slag(w, z)
    inum = sum(z * zl)
    return n / w.s0 * inum / z2ss
def calc(w, z ,n_1, den):
    zl = slag(w,z)
    return n_1 * z * zl / den
Esempio n. 16
0
 def __calc(self, y):
     yl = slag(self.w, y)
     self.num = y * yl
     return self.num.sum() / self.den_sum
Esempio n. 17
0
 def calc(self, w, zx, zy):
     zly = slag(w, zy)
     return self.n_1 * self.zx * zly / self.den
Esempio n. 18
0
 def __calc(self, zy):
     wzy = slag(self.w, zy)
     self.num = (self.zx * wzy).sum()
     self.den = (zy * zy).sum()
     return self.num / self.den
Esempio n. 19
0
 def __calc(self, zy):
     wzy = slag(self.w, zy)
     self.num = (self.zx * wzy).sum()
     self.den = (zy * zy).sum()
     return self.num / self.den
Esempio n. 20
0
 def calc(self, w, zx, zy):
     zly = slag(w, zy)
     return self.n_1 * self.zx * zly / self.den
Esempio n. 21
0
 def __calc(self, y):
     yl = slag(self.w, y)
     self.num = y * yl
     return self.num.sum() / self.den_sum
Esempio n. 22
0
def _calc(z, w, n, z2ss):
    zl = slag(w, z)
    inum = sum(z * zl)
    return n / w.s0 * inum / z2ss