def coh_re(d,rho): from numpy import zeros; pv = zeros(d) for j in range(0,d): pv[j] = rho[j][j].real from entropy import shannon, neumann; coh = shannon(d,pv) - neumann(d,rho) return coh #-----------------------------------------------------------------------------------------------------------------------------------
def coh_re(rho): d = rho.shape[0] pv = np.zeros(d) for j in range(0, d): pv[j] = rho[j][j].real from entropy import shannon, von_neumann coh = shannon(pv) - von_neumann(rho) return coh / math.log(d, 2)
def __init__(self,pkt): self.src = pkt.src self.dst = pkt.dst self.time = pkt.time self.proto = pkt.proto self.pkt_count = 1 self.shannon_pkt = [shannon(self.get_payload(pkt))] self.payload_sizes = [len(self.get_payload(pkt))]
def EoF(rho): pv = np.zeros(2) Ec = concurrence(rho) pv[0] = (1.0 + np.sqrt(1.0 - Ec**2.0)) / 2.0 pv[1] = 1.0 - pv[0] from entropy import shannon EF = shannon(2, pv) return EF
def Svn(d, bv): nbv = np.zeros(d**2-1) for j in range(0, d-1): nbv[j] = bv[j] for j in range(d-1, d**2-1): nbv[j] = 0 dm = gm.rho(d, nbv) pd = np.zeros(d) for j in range(0, d): pd[j] = dm[j, j].real return entropy.shannon(pd)
def SvnHe(d, bvsr, trsr): nbv = np.zeros(d**2-1) for j in range(0, d-1): nbv[j] = bvsr[j] for j in range(d-1, d**2-1): nbv[j] = 0 dm = gm.rho(d, nbv) pd = np.zeros(d) for j in range(0, d): pd[j] = dm[j, j].real svn = entropy.shannon(d, pd) + trsr*(trsr-1) return svn
def shannon(self): return round(shannon(self.payload),4)
def add(self,pkt): self.pkt_count += 1 self.shannon_pkt.append(shannon(self.get_payload(pkt))) self.payload_sizes.append(len(self.get_payload(pkt)))