fix: rename packages to items
This commit is contained in:
parent
d8b470c9d4
commit
5f56b578d2
1 changed files with 14 additions and 14 deletions
28
Probas.py
28
Probas.py
|
@ -9,7 +9,7 @@ import matplotlib.pyplot as pt
|
|||
|
||||
def simulate_NFBP(N):
|
||||
"""
|
||||
Tries to simulate T_i, V_i and H_n for N packages of random size.
|
||||
Tries to simulate T_i, V_i and H_n for N items of random size.
|
||||
"""
|
||||
i = 0 # Nombre de boites
|
||||
R = [0] # Remplissage de la i-eme boite
|
||||
|
@ -43,9 +43,9 @@ def simulate_NFBP(N):
|
|||
|
||||
def stats_NFBP(R, N):
|
||||
"""
|
||||
Runs R runs of NFBP (for N packages) and studies distribution, variance, mean...
|
||||
Runs R runs of NFBP (for N items) and studies distribution, variance, mean...
|
||||
"""
|
||||
print("Running {} NFBP simulations with {} packages".format(R, N))
|
||||
print("Running {} NFBP simulations with {} items".format(R, N))
|
||||
I = []
|
||||
H = [[] for _ in range(N)] # List of empty lists
|
||||
|
||||
|
@ -62,11 +62,11 @@ def stats_NFBP(R, N):
|
|||
|
||||
def stats_NFBP_iter(R, N):
|
||||
"""
|
||||
Runs R runs of NFBP (for N packages) and studies distribution, variance, mean...
|
||||
Runs R runs of NFBP (for N items) and studies distribution, variance, mean...
|
||||
Calculates stats during runtime instead of after to avoid excessive memory usage.
|
||||
"""
|
||||
P=R*N
|
||||
print("Running {} NFBP simulations with {} packages".format(R, N))
|
||||
print("Running {} NFBP simulations with {} items".format(R, N))
|
||||
ISum = 0
|
||||
IVarianceSum = 0
|
||||
HSum = [0 for _ in range(N)]
|
||||
|
@ -100,7 +100,7 @@ def stats_NFBP_iter(R, N):
|
|||
for n in range(N):
|
||||
Hn = HSum[n]/R # moyenne
|
||||
HVariance = sqrt(HSumVariance[n]/(R-1) - Hn**2) # Variance
|
||||
print("Index of bin containing the {}th package (H_{}) : {} (variance {})".format(n, n, Hn, HVariance))
|
||||
print("Index of bin containing the {}th item (H_{}) : {} (variance {})".format(n, n, Hn, HVariance))
|
||||
HSum=[x/R for x in HSum]
|
||||
print(HSum)
|
||||
#Plotting
|
||||
|
@ -113,7 +113,7 @@ def stats_NFBP_iter(R, N):
|
|||
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('Bins (1-{})'.format(N))
|
||||
ax.set_title('T histogram for {} packages (Number of packages in each bin)'.format(P))
|
||||
ax.set_title('T histogram for {} items (Number of items in each bin)'.format(P))
|
||||
ax.legend(loc='upper left',title='Legend')
|
||||
#V plot
|
||||
bx = fig.add_subplot(222)
|
||||
|
@ -121,7 +121,7 @@ def stats_NFBP_iter(R, N):
|
|||
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('Bins (1-{})'.format(N))
|
||||
bx.set_title('V histogram for {} packages (first package size of each bin)'.format(P))
|
||||
bx.set_title('V histogram for {} items (first item size of each bin)'.format(P))
|
||||
bx.legend(loc='upper left',title='Legend')
|
||||
#H plot
|
||||
#We will simulate this part for a asymptotic study
|
||||
|
@ -130,7 +130,7 @@ def stats_NFBP_iter(R, N):
|
|||
cx.set(xlim=(0, N), xticks=np.arange(0, N),ylim=(0, 10), yticks=np.linspace(0, N, 5))
|
||||
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))
|
||||
cx.set_title('H histogram for {} items'.format(P))
|
||||
xb=linspace(0,N,10)
|
||||
yb=Hn*xb/10
|
||||
wb=HVariance*xb/10
|
||||
|
@ -141,7 +141,7 @@ def stats_NFBP_iter(R, N):
|
|||
|
||||
def simulate_NFDBP(N):
|
||||
"""
|
||||
Tries to simulate T_i, V_i and H_n for N packages of random size.
|
||||
Tries to simulate T_i, V_i and H_n for N items of random size.
|
||||
"""
|
||||
i = 0 # Nombre de boites
|
||||
R = [0] # Remplissage de la i-eme boite
|
||||
|
@ -176,9 +176,9 @@ def simulate_NFDBP(N):
|
|||
|
||||
def stats_NFDBP(R, N,t_i):
|
||||
"""
|
||||
Runs R runs of NFDBP (for N packages) and studies distribution, variance, mean...
|
||||
Runs R runs of NFDBP (for N items) and studies distribution, variance, mean...
|
||||
"""
|
||||
print("Running {} NFDBP simulations with {} packages".format(R, N))
|
||||
print("Running {} NFDBP simulations with {} items".format(R, N))
|
||||
P=N*R
|
||||
I = []
|
||||
H = [[] for _ in range(N)] # List of empty lists
|
||||
|
@ -232,7 +232,7 @@ def stats_NFDBP(R, N,t_i):
|
|||
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('Bins (1-{})'.format(N))
|
||||
ax.set_title('Items percentage for each bin and {} packages (Number of packages in each bin)'.format(P))
|
||||
ax.set_title('Items percentage for each bin and {} items (Number of items 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.
|
||||
|
@ -242,7 +242,7 @@ def stats_NFDBP(R, N,t_i):
|
|||
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('Bins i=(1-{}) in %'.format(N))
|
||||
bx.set_title('T{} histogram for {} packages (Number of packages in each bin)'.format(t_i,P))
|
||||
bx.set_title('T{} histogram for {} items (Number of items in each bin)'.format(t_i,P))
|
||||
bx.legend(loc='upper left',title='Legend')
|
||||
|
||||
#Loi mathematique
|
||||
|
|
Loading…
Reference in a new issue