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

Complete binomial dist #33

Closed
wants to merge 5 commits into from
Closed

Conversation

envp
Copy link
Member

@envp envp commented Jan 24, 2016

This PR is so far just these two commits:

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

  • Added development dependency pry as an alternative to irb
  • Documentaion done in yardoc format
  • Added Distribution::Binomial::GSL_.rng that wraps gsl_ran_binomial(3)
  • Added a fast but ad-hoc implementaion for binomial inverse-CDF
  • Loads of comments and documentation for binomial

Changelog: Updated ruby implementation of inverse CDF and added RNG to Distribution::Binomial::Ruby

  • Updated ruby quantile function to also be a binary search (O(n) -> O(log n) improvement, may be unstable; requires testing)
  • Added an RNG for binomial distribution (see implementation for details)
  • Updated documentation in distribution/binomial/ruby.rb

Updates

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

  • Added RNG tests
  • Reverted changes in quantile function introduced in previous commits, becuase original was ~3x(?) faster.
  • ALL TESTS PASSING

This is in partial fulfillment of #21
Maintained TODO List: #21 (comment)

envp added 4 commits January 24, 2016 20:29
* Added development dependency pry as an alternative to irb
* Documentaion done in yardoc format
* Added Distribution::Binomial::GSL_.rng that wraps the gsl_ran_binomial(3)
* Added a fast but ad-hoc implementaion for binomial inverse-CDF
* Loads of comments and documentation for binomial
…o Distribution::Binomial::Ruby_

* Updated ruby quantile function to also be a binary search (O(n) -> O(log n) improvement, may be unstable; requires testing)
* Added an RNG for binomial distribution (see implementation for details)
* Updated documentation in distribution/binomial/ruby.rb
… distribution and added various tests for RNG

* Added RNG tests
* Reverted changes in quantile function introduced in previous commits, becuase original was ~3x(?) faster.
* ALL TESTS PASSING
@envp
Copy link
Member Author

envp commented Jan 26, 2016

@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
Copy link
Member

agarie commented Feb 1, 2016

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

@envp
Copy link
Member Author

envp commented Feb 1, 2016

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
Copy link
Member Author

envp commented Sep 25, 2016

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

@envp envp closed this Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants