I have this data,
How do I create a multi bootstrap n number of times and plot the bar chart in Python?
I have tried doing the below. But it is not returning any value
1 2 3 4 5 6 7 8 9 10 11 12 13 |
def single_bootstrap(): bootstrap = np.zeros([ 101 , 2 ]) bootstrap[:, 0 ] = range ( 0 , 101 ) n = int ( 5e5 ) for i in range (n): i = np.random.randint ( 1 , n + 1 ) age = int (np.argwhere(stairs>i)[ 0 ]); bootstrap[age, 1 ] + = 1 return bootstrap |
I have tried doing the below. But it is not returning any value
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
def multi_bootstrap(number_times): multi_bootstrap = [] for j in range (number_times): bootstrape = single_bootstrap() multi_bootstrap.append([bootstrape[:, 1 ]]) return multi_bootstrap number_times = 50 ; multi_bootstraps = multi_bootstrap(number_times) for i in range (number_times): plt.plot (np.arange( 0 , 101 ), age_counts, multi_bootstraps) plt.xlabel( 'Age' ) plt.ylabel( 'Count' ) plt.title( 'Age Distribution of Population in Manchester' ) plt.show() |