# -*- coding: utf-8 -*- """ Created on Thu Aug 11 16:22:27 2022 @author: Rene """ import numpy as np import matplotlib.pyplot as plt import Dist_Library as dl n = 10 m = 100000 sample_matrix = np.zeros((m, n)) for i in np.arange(0,m): x = np.random.choice(a=n, size=n, replace=False) x = x + 1 sample_matrix[i,:] = x outcomes = np.arange(1,n+1) plt.rc('font', family='serif', size='10') Figure = plt.figure() Figure.set_figwidth(10) Figure.set_figheight(4) Figure.subplots_adjust(hspace=0.4, wspace=0.4) #******************************************************** LB_x = 1 UB_x = 10 off_set_x = 1 LB_y = 0 UB_y = 0.2 off_set_y = 0.01 x_lims = (LB_x-off_set_x,UB_x+off_set_x) y_lims = (LB_y-off_set_y,UB_y+off_set_y) Panel = Figure.add_subplot(1,2,1) j = 0 pmf = dl.Estimate_empirical_pmf(outcomes,sample_matrix[:,j]) plt.xlim(x_lims) plt.ylim(y_lims) plt.xlabel('i') plt.ylabel('$Pr(X_1 = i)$') ticks = np.arange(1,11) plt.xticks(ticks) plt.grid(b=None, which='major', axis='both',ls='--',lw=0.5) plt.axvline(0, lw=2, ls = '-',color = 'lightgray',alpha=0.5) plt.axhline(0, lw=2, ls = '-',color = 'lightgray',alpha=0.5) plt.scatter(ticks,pmf,color='red') for i in np.arange(0,10): x_values = [ticks[i],ticks[i]] y_values = [0,pmf[i]] plt.plot(x_values,y_values,color='blue',alpha=0.5) text_str = "repetitions =" + f'{m:,}' plt.text(0.5,0.2,text_str, size=15, color = 'red', horizontalalignment = 'left', verticalalignment = 'center') Panel.title.set_text('PMF First draw without Replacement') Panel = Figure.add_subplot(1,2,2) j = 1 pmf = dl.Estimate_empirical_pmf(outcomes,sample_matrix[:,j]) plt.xlim(x_lims) plt.ylim(y_lims) plt.xlabel('i') plt.ylabel('$Pr(X_2 = i)$') ticks = np.arange(1,11) plt.xticks(ticks) plt.grid(b=None, which='major', axis='both',ls='--',lw=0.5) plt.axvline(0, lw=2, ls = '-',color = 'lightgray',alpha=0.5) plt.axhline(0, lw=2, ls = '-',color = 'lightgray',alpha=0.5) plt.scatter(ticks,pmf,color='red') for i in np.arange(0,10): x_values = [ticks[i],ticks[i]] y_values = [0,pmf[i]] plt.plot(x_values,y_values,color='blue',alpha=0.5) text_str = "repetitions =" + f'{m:,}' plt.text(0.5,0.2,text_str, size=15, color = 'red', horizontalalignment = 'left', verticalalignment = 'center') Panel.title.set_text('PMF Second draw without Replacement') plt.savefig("PMFS_sampling_without_replacement_1.png", dpi=300)