Python Forum

Full Version: Bootstrapping a population data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have this data,

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
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

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()