Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When r=d=500, it does not work #1

Open
XingLiu93 opened this issue Sep 18, 2017 · 2 comments
Open

When r=d=500, it does not work #1

XingLiu93 opened this issue Sep 18, 2017 · 2 comments

Comments

@XingLiu93
Copy link

XingLiu93 commented Sep 18, 2017

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

@Wolfi-101
Copy link

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:

  1. 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.
  2. 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.

Hope this helps

@Hsgngr
Copy link

Hsgngr commented Jan 29, 2021

I have the same issue on my Windows while my colleague didn't get any error in his mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants