def compute_stats(self):
    for i,v in enumerate([0] * N):
      self.nodes_stats.append([])

    for idx, subset in enumerate(self.subsets):

      # load esperimental parameters
      gamma   = float(subset[0]["gamma"])
      sim_time = float(subset[0]["sim_time"])
      num_nodes = int(subset[0]["num_nodes"])
      
      repetition = count_distinct(subset, "repetition")

      byte_offered = column(subset, "offered")
      byte_sent    = column(subset, "sent")
      byte_load    = column(subset, "load")
      perc_success = column(subset, "perc_success")
      byte_lost    = column(subset, "losses")
      
      i_load        = sum(byte_load)/sim_time/repetition*convert_megabyte
      i_throughput  = sum(byte_sent)/sim_time/repetition*convert_megabyte
      i_offered     = sum(byte_offered)/sim_time/repetition*convert_megabyte
      i_lost        = sum(byte_lost)/sim_time/repetition*convert_megabyte
      i_collided    = i_offered - i_throughput
      i_correct_p    = avg(perc_success)

      i_computed_load = mean_packet_size / expon.mean(loc=0, scale=gamma) * num_nodes * convert_megabyte

      self.rate.append(1/gamma)
      self.load.append(i_load)
      self.computed_load.append(i_computed_load)
      self.offered.append(i_offered)
      self.throughput.append(i_throughput)
      self.lost.append(i_lost)
      self.collided.append(i_collided)
      self.perc.append(i_correct_p)
      self.throughput_nodes.append([sent/sim_time for sent in byte_sent])

      #print(gamma, " - p:", mean_packet_size, " > ", i_load, " = ", i_computed_load)

      # add offered load statistic for every node to undestand network topology behaviour
      subset_nodes = split_int(subset, "node")
      for n, sub in enumerate(subset_nodes):
        byte_offered = column(sub, "offered")
        perc_success = column(sub, "perc_success")

        n_offered = avg(byte_offered)/sim_time*convert_megabyte
        p = avg(perc_success)
        self.nodes_stats[n].append(n_offered)
Пример #2
0
 def mean(self, dist):
     return expon.mean(*self._get_params(dist))
Пример #3
0
 def mean(self, n, p):
     mu = expon.mean(self, n, p)
     return mu
Пример #4
0
plt.title('Cor/tamanho: mais claro => maior Dsv Digital')
plt.xlabel('Poder Militar')
plt.ylabel('IDH')
plt.scatter(milpow, idh, c=digdev, s=digdev * 100)
plt.show()
#%%
plt.figure()
plt.title('Cor/tamanho: mais claro => maior Seg Ciber')
plt.xlabel('Dsv Digital')
plt.ylabel('IDH')
plt.scatter(digdev, idh, c=cibsec, s=cibsec * 100)
plt.show()
#%%
plt.figure()
loc, scale = expon.fit(np.divide(1, milpow))
mu_mil = expon.mean(loc=loc, scale=scale)
plt.hist(np.divide(1, milpow), density=1, label='Media=%.2f' % mu_mil)
x = np.linspace(min(np.divide(1, milpow)), max(np.divide(1, milpow)))
plt.plot(x, expon.pdf(x, loc=loc, scale=scale))
plt.title('Poder Militar')
plt.legend(loc='best')
plt.show()
#%%
plt.figure()
c, loc, scale = weibull_min.fit(cibsec)
mu_cib = weibull_min.mean(c, loc=loc, scale=scale)
plt.hist(cibsec, density=1, label='Media=%.2f' % mu_cib)
x_cib = np.linspace(min(cibsec), max(cibsec))
plt.plot(x_cib, weibull_min.pdf(x_cib, c, loc=loc, scale=scale))
plt.title('Segurança Cibernética')
plt.legend(loc='best')
Пример #5
0
print(aVec)
# random numbers from multivariate normal
# does not give Multivariate normal!
print('MULTI?! Does not give multivariate Normal!')
rvs = norm.rvs(loc=np.array([0, 1]), scale=np.array([[1, 0], [0, 1]]))
print(rvs)
print('\n\n')
#############################################################
#############################################################
# In general the standardized distribution for a random variable X is
# obtained through the transformation (X - loc) / scale. The
# default values are loc = 0 and scale = 1.
print('exponential dist')
print(expon.stats())
# for exponential dist scale=1/lambda
print(expon.mean(scale=3))

print('UNIFORM!!!:')
# This distribution is constant between loc and loc + scale.
from scipy.stats import uniform
print(uniform.cdf([0, 1, 2, 34, 5], loc=1, scale=4))
print(np.mean(norm.rvs(5, size=500)))
# shape parameters:
from scipy.stats import gamma
print('GAMMA')
print(gamma(a=1, scale=2).stats(moments="mv"))
print(gamma.stats(a=1, scale=2, moments="mv"))

###################################################
# freezing a distribution:
rv = gamma(a=1, scale=2)