fix: rename boxes to bins
This commit is contained in:
parent
8284d7bf03
commit
d8b470c9d4
1 changed files with 14 additions and 14 deletions
28
Probas.py
28
Probas.py
|
@ -55,7 +55,7 @@ def stats_NFBP(R, N):
|
|||
for n in range(N):
|
||||
H[n].append(sim["H"][n])
|
||||
|
||||
print("Mean number of boxes : {} (variance {})".format(mean(I), variance(I)))
|
||||
print("Mean number of bins : {} (variance {})".format(mean(I), variance(I)))
|
||||
|
||||
for n in range(N):
|
||||
print("Mean H_{} : {} (variance {})".format(n, mean(H[n]), variance(H[n])))
|
||||
|
@ -94,13 +94,13 @@ def stats_NFBP_iter(R, N):
|
|||
print(Sum_V)
|
||||
I = ISum/R
|
||||
IVariance = sqrt(IVarianceSum/(R-1) - I**2)
|
||||
print("Mean number of boxes : {} (variance {})".format(I, IVariance),'\n')
|
||||
print("Mean number of bins : {} (variance {})".format(I, IVariance),'\n')
|
||||
print(" {} * {} iterations of T".format(R,N),'\n')
|
||||
|
||||
for n in range(N):
|
||||
Hn = HSum[n]/R # moyenne
|
||||
HVariance = sqrt(HSumVariance[n]/(R-1) - Hn**2) # Variance
|
||||
print("Index of box containing the {}th package (H_{}) : {} (variance {})".format(n, n, Hn, HVariance))
|
||||
print("Index of bin containing the {}th package (H_{}) : {} (variance {})".format(n, n, Hn, HVariance))
|
||||
HSum=[x/R for x in HSum]
|
||||
print(HSum)
|
||||
#Plotting
|
||||
|
@ -112,23 +112,23 @@ def stats_NFBP_iter(R, N):
|
|||
ax.bar(x,Sum_T, width=1,label='Empirical values', edgecolor="blue", linewidth=0.7,color='red')
|
||||
ax.set(xlim=(0, N), xticks=np.arange(0, N),ylim=(0,3), yticks=np.linspace(0, 3, 5))
|
||||
ax.set_ylabel('Items')
|
||||
ax.set_xlabel('Boxes (1-{})'.format(N))
|
||||
ax.set_title('T histogram for {} packages (Number of packages in each box)'.format(P))
|
||||
ax.set_xlabel('Bins (1-{})'.format(N))
|
||||
ax.set_title('T histogram for {} packages (Number of packages in each bin)'.format(P))
|
||||
ax.legend(loc='upper left',title='Legend')
|
||||
#V plot
|
||||
bx = fig.add_subplot(222)
|
||||
bx.bar(x,Sum_V, width=1,label='Empirical values', edgecolor="blue", linewidth=0.7,color='orange')
|
||||
bx.set(xlim=(0, N), xticks=np.arange(0, N),ylim=(0, 1), yticks=np.linspace(0, 1, 10))
|
||||
bx.set_ylabel('First item size')
|
||||
bx.set_xlabel('Boxes (1-{})'.format(N))
|
||||
bx.set_title('V histogram for {} packages (first package size of each box)'.format(P))
|
||||
bx.set_xlabel('Bins (1-{})'.format(N))
|
||||
bx.set_title('V histogram for {} packages (first package size of each bin)'.format(P))
|
||||
bx.legend(loc='upper left',title='Legend')
|
||||
#H plot
|
||||
#We will simulate this part for a asymptotic study
|
||||
cx = fig.add_subplot(223)
|
||||
cx.bar(x,HSum, width=1,label='Empirical values', edgecolor="blue", linewidth=0.7,color='green')
|
||||
cx.set(xlim=(0, N), xticks=np.arange(0, N),ylim=(0, 10), yticks=np.linspace(0, N, 5))
|
||||
cx.set_ylabel('Box ranking of n-item')
|
||||
cx.set_ylabel('Bin ranking of n-item')
|
||||
cx.set_xlabel('n-item (1-{})'.format(N))
|
||||
cx.set_title('H histogram for {} packages'.format(P))
|
||||
xb=linspace(0,N,10)
|
||||
|
@ -203,7 +203,7 @@ def stats_NFDBP(R, N,t_i):
|
|||
Sum_T=[x/R for x in Sum_T] #Experimental [Ti=k]
|
||||
Sum_T=[x*100/(sum(Sum_T)) for x in Sum_T] #Pourcentage de la repartition des items
|
||||
|
||||
print("Mean number of boxes : {} (variance {})".format(mean(I), variance(I)))
|
||||
print("Mean number of bins : {} (variance {})".format(mean(I), variance(I)))
|
||||
|
||||
for n in range(N):
|
||||
print("Mean H_{} : {} (variance {})".format(n, mean(H[n]), variance(H[n])))
|
||||
|
@ -231,8 +231,8 @@ def stats_NFDBP(R, N,t_i):
|
|||
ax.bar(x,Sum_T, width=1,label='Empirical values', edgecolor="blue", linewidth=0.7,color='red')
|
||||
ax.set(xlim=(0, N), xticks=np.arange(0, N),ylim=(0,20), yticks=np.linspace(0, 20, 2))
|
||||
ax.set_ylabel('Items(n) in %')
|
||||
ax.set_xlabel('Boxes (1-{})'.format(N))
|
||||
ax.set_title('Items percentage for each box and {} packages (Number of packages in each box)'.format(P))
|
||||
ax.set_xlabel('Bins (1-{})'.format(N))
|
||||
ax.set_title('Items percentage for each bin and {} packages (Number of packages in each bin)'.format(P))
|
||||
ax.legend(loc='upper left',title='Legend')
|
||||
|
||||
#Mathematical P(Ti=k) plot. It shows the Ti(t_i) law with the probability of each number of items.
|
||||
|
@ -241,8 +241,8 @@ def stats_NFDBP(R, N,t_i):
|
|||
bx.hist(Tk[t_i],bins=10, width=1,label='Empirical values', edgecolor="blue", linewidth=0.7,color='red')
|
||||
bx.set(xlim=(0, N), xticks=np.arange(0, N),ylim=(0,len(Tk[t_i])), yticks=np.linspace(0, 1, 1))
|
||||
bx.set_ylabel('P(T{}=i)'.format(t_i))
|
||||
bx.set_xlabel('Boxes i=(1-{}) in %'.format(N))
|
||||
bx.set_title('T{} histogram for {} packages (Number of packages in each box)'.format(t_i,P))
|
||||
bx.set_xlabel('Bins i=(1-{}) in %'.format(N))
|
||||
bx.set_title('T{} histogram for {} packages (Number of packages in each bin)'.format(t_i,P))
|
||||
bx.legend(loc='upper left',title='Legend')
|
||||
|
||||
#Loi mathematique
|
||||
|
@ -251,7 +251,7 @@ def stats_NFDBP(R, N,t_i):
|
|||
cx.bar(x,T_maths, width=1,label='Theoretical values', edgecolor="blue", linewidth=0.7,color='red')
|
||||
cx.set(xlim=(0, N), xticks=np.arange(0, N),ylim=(0,100), yticks=np.linspace(0, 100, 10))
|
||||
cx.set_ylabel('P(T{}=i)'.format(t_i))
|
||||
cx.set_xlabel('Boxes i=(1-{})'.format(N))
|
||||
cx.set_xlabel('Bins i=(1-{})'.format(N))
|
||||
cx.set_title('Theoretical T{} values in %'.format(t_i))
|
||||
cx.legend(loc='upper left',title='Legend')
|
||||
plt.show()
|
||||
|
|
Loading…
Reference in a new issue