Closed igordertigor closed 5 years ago
I apologize for the delayed response! Life got busy with moving ...
That is odd ... will look into the issue further in the coming days.
Given your example I have replicated the error.
There appears to be two issues here. One is the sequencing error, which still needs to be fixed.
The second is the prior set. A prior with a mean of 0.5 does not make sense for data whose intensities range between 1 - 10. Changing the mean value estimate to 5 [ 'Norm(5,1)' ] will appropriately fit a function, with a MAP value estimate for the mu of the normal distribution at 3.42, which makes sense. No errors are output from the example code below.
That code is:
metrics, options = bf.fitmodel(data, priors=('Norm(5,1)', None, None, None), param_free=[True, True, True, False])
I re-read the issue you raise, and realize I missed that you explicitly set this prior to be off the mark in order to see what happens.
Will look into this further ...
@SlugocM , I'm not sure what you mean by the "sequencing error". Good luck with the move!
@igordertigor Thank you all around! Finally tracked down the error.
The probability vector returned for a prior that is way off the mark is an array of zeros. Of course, in theory these values are not zero, but are extremely small. However, in practice, they come back as zeros even if you use a double data type in an attempt to capture them.
Now, in the implementation, the vector representing the probabilities of a user provided prior are normalized before being applied to the likelihood surface to generate a posterior. Therefore, the vector of zeros was being divided by its sum, which is zero, resulting in an error that propagated forward... the details of which I will save. In short, it resulted in a sequence being returned instead of an array when computing one of the metrics from the posterior.
I have have updated the master branch with a fix that addresses this issue by checking whether the sum of the vector of probabilities for user defined priors is equal to zero. If so, an informative Value Error arises that tells the user that one of the priors they have provided is likely way off the mark, and so either to adjust the priors, or to use MLE by setting priors equal to None.
I will now close the issue :)
Sounds good. Thanks for looking into this.
Here is a textfile I am using:
Note that I explicitly multiply my stimulus values to a range that really doesn't match with the prior. This gives the following error:
Removing the multiplication or setting the prior to
'Norm(0.3, 0.01)'
solves the problem and gives a reasonable looking function.