Create random numbers of 150 and take a uniform sample of 78
import numpy as np
population_data=np.random.randint(1,600,150) # 150 random numbers(integers) genereated
sample_data=[]
sample_lenth=78
p=30/len(population_data)
for i in range(1,len(population_data)):
if np.random.random() <=p:
sample_data.append(population_data[i])
print(i,len(sample_data))
if sample_lenth==len(sample_data):
break;
else:
i=10 # (basically wants to change the i value lower that for loop keep running )
print(i)
print(len(sample_data))
print(sample_data)
for loop is running still 150 which is valid and I cant add more range in for loop as if i>150 then sample_data.append(population_data[i] ) will be out of range.
What I want to achieve is: if sample_lenth==len(sample_data): then break else change the i value to any in between 1-150 that loop continues
Any help !!