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

Sampling bug in C++ Normal Inverse Wishart #6

Open
fritzo opened this issue Feb 10, 2015 · 5 comments
Open

Sampling bug in C++ Normal Inverse Wishart #6

fritzo opened this issue Feb 10, 2015 · 5 comments
Labels

Comments

@fritzo
Copy link
Member

fritzo commented Feb 10, 2015

The new stronger statistical tests indicate a bug in the C++ version of Normal-Inverse-Wishart sampler. I assume the bug is in the sampling code in random.hpp (python sampler and scorer agree as per test_models.py:test_sample_value, and python and c++ scoring agree as per test_model_flavors.py:test_group, pointing to C++ sampling as the culprit.

This is now disabled in unit tests.

@fritzo fritzo added the bug label Feb 10, 2015
@fritzo
Copy link
Member Author

fritzo commented Feb 10, 2015

The lp version is seen to clearly fail where the dbg version passes, using the script

$ python derivations/vector_gof.py plot-cdf
$ python derivations/vector_gof.py scatter

See plots below

@fritzo
Copy link
Member Author

fritzo commented Feb 10, 2015

Disabling the SkipTest, we see

$ nosetests -v distributions/tests/test_models.py:test_sample_value
distributions.tests.test_models.test_sample_value('dbg.models.bb',) ... ok
distributions.tests.test_models.test_sample_value('dbg.models.dpd',) ... ok
distributions.tests.test_models.test_sample_value('dbg.models.bnb',) ... ok
distributions.tests.test_models.test_sample_value('lp.models.dpd',) ... ok
distributions.tests.test_models.test_sample_value('lp.models.bb',) ... ok
distributions.tests.test_models.test_sample_value('lp.models.bnb',) ... ok
distributions.tests.test_models.test_sample_value('dbg.models.nich',) ... ok
distributions.tests.test_models.test_sample_value('hp.models.nich',) ... ok
distributions.tests.test_models.test_sample_value('dbg.models.dd',) ... ok
distributions.tests.test_models.test_sample_value('dbg.models.gp',) ... ok
distributions.tests.test_models.test_sample_value('hp.models.gp',) ... ok
distributions.tests.test_models.test_sample_value('hp.models.dd',) ... ok
distributions.tests.test_models.test_sample_value('dbg.models.niw',) ... ok
distributions.tests.test_models.test_sample_value('lp.models.nich',) ... ok
distributions.tests.test_models.test_sample_value('lp.models.gp',) ... ok
distributions.tests.test_models.test_sample_value('lp.models.dd',) ... ok
distributions.tests.test_models.test_sample_value('lp.models.niw',) ... FAIL
======================================================================
FAIL: distributions.tests.test_models.test_sample_value('lp.models.niw',)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fritz/.virtualenvs/posterior/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/fritz/posterior/distributions/distributions/tests/test_models.py", line 104, in test_one_model
    test_fun(module, EXAMPLE)
  File "/home/fritz/posterior/distributions/distributions/tests/test_models.py", line 402, in test_sample_value
    assert_greater(gof, MIN_GOODNESS_OF_FIT)
AssertionError: 0.00018875054387771975 not greater than 0.001
--------------------  begin captured stdout  ---------------------
example 1/4
    Prob    Count
   0.048      543 ------------------------------------------------------------
   0.048      539 ------------------------------------------------------------
   0.048      527 ----------------------------------------------------------
   0.048      511 --------------------------------------------------------
   0.048      504 --------------------------------------------------------
   0.048      495 -------------------------------------------------------
   0.048      487 ------------------------------------------------------
   0.048      485 ------------------------------------------------------
   0.048      472 ----------------------------------------------------
   0.048      470 ----------------------------------------------------
   0.048      468 ----------------------------------------------------
   0.048      465 ---------------------------------------------------
   0.048      462 ---------------------------------------------------
   0.048      462 ---------------------------------------------------
   0.048      459 ---------------------------------------------------
   0.048      455 --------------------------------------------------
   0.048      454 --------------------------------------------------
   0.048      451 --------------------------------------------------
   0.048      449 --------------------------------------------------
   0.048      424 -----------------------------------------------
   0.048      418 ----------------------------------------------
distributions.lp.models.niw gof = 0.000189
---------------------  end captured stdout  ----------------------
----------------------------------------------------------------------
Ran 17 tests in 31.970s
FAILED (failures=1)

@fritzo
Copy link
Member Author

fritzo commented Feb 10, 2015

@stephentu FYI

@fritzo
Copy link
Member Author

fritzo commented Feb 10, 2015

$ python derivations/vector_gof.py plot-cdf

vector-gof-cdf

@fritzo
Copy link
Member Author

fritzo commented Feb 10, 2015

$ python derivations/vector_gof.py scatter

vector-gof-scatter
(reds and blues should be uniformly distributed)

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

No branches or pull requests

1 participant