In <e9f1d94f-4dd6-49b5-bf5c-bbcdc8d30...@googlegroups.com> Robert <rxjw...@gmail.com> writes:
> //////////// > # represent the experiments > head_counts = np.array([5,9,8,4,7]) The code doesn't define 'np', so this line should produce an error. The code you linked contains this import: import numpy as np However you didn't show it here, so I wonder if you posted the real code. > sum(expectation_A)[0] > --------------------------------------------------------------------------- > IndexError Traceback (most recent call last) > <ipython-input-145-d6f33dff0343> in <module>() > ----> 1 sum(expectation_A)[0] > IndexError: invalid index to scalar variable. > ////////////// The built-in function sum() returns a single value, not a list, so this is a reasonable error. I suspect the code actually intended to call numpy.sum(), which does return a list (or something like a list). -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list