Python Forum
Bootstrapping a population data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bootstrapping a population data
#1
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()
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020