I have one for loop by which I am generating some random daily value for each month. I need to make it sure that the generated monthly mean value should equal to the observed mean value (provided in different dataframe). So I need to run this for loop until the desired value is generated and after that it again run for next month.
I have sample code but not sure how to run it several time until to get desired value:
for j in np.arange(1,13,1):
# calculating monthly leanth from provided datasets
mlen = ((df_test[df_test.index.year==2000]).index.month==j).sum()
# fit to my distribution
phat = stats.exponweib.fit((df_test[df_test.index.month==j].mean(axis=1)).dropna())
# predicting based on the fitted distribution
esti = stats.exponweib.rvs(*phat,int(mlen))
if esti.mean() == monthly_mean[0]
Where monthly_mean is the observed monthly mean value is its look like below, where the first value for the first month.
monthly_mean = array([ 5.15 , 5.948571, 7.028261, 4.144231, 3.585965,
5.244828, 4.915455, 4.757 , 5.803614, 12.573684,
5.683333, 3.875 ])
any help/suggestion is highly appriciated!
Aucun commentaire:
Enregistrer un commentaire