SciRuby / distribution

Probability distributions for Ruby.
http://sciruby.com/
Other
50 stars 21 forks source link

Complete binomial dist #33

Closed envp closed 5 years ago

envp commented 8 years ago

This PR is so far just these two commits:

Changelog: Add GSL_.rng & GSL_.quantile for binomial distribution

I ran the rspec tests one by one and found that this one gets stuck (the testcases starting on lines 70, 86 are fine)

line 72 gets stuck for some reason. Pending an analysis. Something tells me this is related to how I changed the :p_value method, and is resulting in a cycle(?).

This was because the new quantile implemented made calls to cdf, which being slow O(N) died or stalled, when asked to do this for 500 x 2 x something test values. Removed the binary search based quantile method altogether as a result of this.

1/26/16: Added the following commit to fix all issues and add tests:

Changelog: Reverted GSL_.quantile and Ruby_.quantile for binomial distribution and added various tests for RNG

This is in partial fulfillment of #21 Maintained TODO List: https://github.com/SciRuby/distribution/issues/21#issuecomment-172246401

envp commented 8 years ago

@clbustos @mohawkjohn @agarie Can you please have a look at this?

I also wanted to add something like https://gist.github.com/vaibhav-y/9cee23e880ed5a76f218 more specifically the __binary_search_inv(lower, upper, predicate, mid_proportion) function defined there, where would be the best place to add that ?

2/1/2016: Still pending.

agarie commented 8 years ago

Huh, I restarted the build on Travis to see if the tests are OK. Again, I'll merge once the tests are green.

envp commented 8 years ago

Please don't merge binomial yet, I've across some interesting papers and references for finalizing the implementation, mainly the following.

  1. R's rbinom.c: https://github.com/SurajGupta/r-source/blob/master/src/nmath/rbinom.c
  2. BTRD algorithm, p6 of http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.47.8407&rep=rep1&type=pdf
  3. Luc Devroye, p533 luc.devroye.org/chapter_ten.pdf

Sadly, I'm yet to fully grasp what each of these is fully doing.

envp commented 8 years ago

Apologies for the delay! Current status is on-hold. I'll get back to implementing this after school exams are done.