On Thursday, June 19, 2014 7:57:38 PM UTC+5:30, wrote: > On Thursday, June 19, 2014 7:39:42 PM UTC+5:30, Ian wrote: > > > On Thu, Jun 19, 2014 at 3:48 AM, wrote: > > > > > > > I am trying to see this line, > > > > > > > prev_f_sum = sum(f_prev[k]*a[k][st] for k in states) > > > > > > > > > > > > > > a[k][st], and f_prev[k] I could take out and understood. > > > > > > > Now as it is doing sum() so it must be over a list, > > > > > > > I am trying to understand the number of entities in the list, thinking > > > whether to put len(), and see for which entities it is doing the sum. > > > > > > > > > > > > It's summing a generator expression, not a list. If it helps to > > > > > > understand it, you could rewrite that line like this: > > > > > > > > > > > > values_to_be_summed = [] > > > > > > for k in states: > > > > > > values_to_be_summed.append(f_prev[k]*a[k][st]) > > > > > > prev_f_sum = sum(values_to_be_summed) > > > > > > > > > > > > So the number of entities in the list is len(states). > > > > Dear Group, > > > > Thank you for your kind answer. As I put from the error I discovered it. > Please see my experiment almost near to your answer. I am trying one or two > questions like, why it is appending only two values at a time. If you want to > assist you may kindly help me assist me. > > Regards, > > Subhabrata Banerjee. > > ******************************************************************************* > > MY EXPERIMENT > > ******************************************************************************* > > else: > > for k in states: > > print "YYY1",f_prev[k] > > print "YYY2",a[k][st] > > prev_f_sum1=f_prev[k]*a[k][st] > > print "YYY3",prev_f_sum1 > > prev_f_sum2 = sum(f_prev[k]*a[k][st] for k in > states) > > print "YYY4",prev_f_sum2 > > ******************************************************************************* Dear Group, Generally most of the issues are tackled here, but as I am trying to cross check my understanding I found another question,
f_curr[st] = e[st][x_i] * prev_f_sum Here, if I give one print command and see the results, print "$$2",f_curr It is showing an iterative update like, $$2 {'Healthy': 0.3}, $$2 {'Healthy': 0.3, 'Fever': 0.04000000000000001} I was trying to ask how the size is being updated, from 1 to 2 back to 1 again 2... is it for any loop then which one, I tried to change but not being able to if any one of the esteemed members may kindly help me. Regards, Subhabrata Banerjee. -- https://mail.python.org/mailman/listinfo/python-list