manishravula/irlfortypes

Polynomial normalization failing.

Closed this issue · 2 comments

Polynomial normalization for posterior calculation at each step, is failing sometimes which ends up raising an assert error through the self-check based in tests/tests_helper.py.

This is observed to happen only after iter-4 of running the experiments/singleTypeEstima... file.

Traceback:

Traceback (most recent call last):
  File "/home/manish/Awesomestuff/AdHocTeamWork/AdHoc2/experiments/singleTypeParameterEstimationExperiment.py", line 100, in <module>
    estimates, posterior = abu.estimate_allTypes(i)
  File "/home/manish/Awesomestuff/AdHocTeamWork/AdHoc2/src/ABU_estimator.py", line 338, in estimate_allTypes
    updated_posterioirPoly,pestim_sample,pestim_max = self.estimate_parameter(likelihood_polyCoeffs,prior_polyCoeffs)
  File "/home/manish/Awesomestuff/AdHocTeamWork/AdHoc2/src/ABU_estimator.py", line 316, in estimate_parameter
    Tests.test_for_normalization(posteriorProb_polyCoeffs_normalized,self.xrange)
  File "/home/manish/Awesomestuff/AdHocTeamWork/AdHoc2/tests/tests_helper.py", line 47, in test_for_normalization
    assert diff_from_one_2<epsilon, 'Not normalized poly with error 2 {}, {}'.format(diff_from_one_2, diff_from_one)
AssertionError: Not normalized poly with error 2 0.0226803019973, 0.013163887049

Also, it is not associated with a specific type. Fails after iter 4, but no definite type.

13e3aa3 solves this.
The bug arose because after multiplying prior and likelihood, the polynomial was not rescaled back to its original degree. So, the polynomial has been growing exponentially in degree.