You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For me, the "setting an array with a sequence" error came up if the minimum of the cost function occurred more than once, i.e. the line np.where(cost[t,:] == min(cost[t,:])) returned an array with more than one entry. I know of two situations where this can happen:
The probability for both states is the same. This happens if s=1. At the first timestep, the fit function will return the same value for both states. To avoid this, assert that s>1.
The values for r and d are too high. In the fit function, the value for the binomial coefficient and the probabilities p^r and (1-p)^(d-r) are computed separately. If d is very large, for example d>100000, the binomial coefficient will be np.inf or the whole thing will evaluate to np.nan. I chose to use scipy.stats.binom.pmf(k=r, n=d, p=p) which avoids these separate calculations and returns the value of the probability mass function straight away.
Hi, I met a problem when I use the program. When I test with 500 elements on r and d, it always has error:
ValueError: setting an array element with a sequence.
But with the same data, when len(r)=len(d)=20, it works. Do you know why?
This is my questions. https://stackoverflow.com/questions/46270121/python-program-error-valueerror-setting-an-array-element-with-a-sequence
Thanks
The text was updated successfully, but these errors were encountered: