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

Unify the specification of distribution supports #312

Merged
merged 7 commits into from
Nov 17, 2014
Merged

Conversation

lindahua
Copy link
Contributor

This PR introduces a new macro distr_support, which works for almost all univariate distributions that specify the support of the distribution. For example,

@distr_support Normal -Inf Inf
@distr_support Uniform d.a d.b
@distr_support Geometric 0 Inf

This macro can be used for various cases, no matter whether the support is bounded or not, or whether the support can be determined at the class-level or at the instance-level.

This macro will generate the following methods:

  • insupport
  • support, which returns a UnitRange instance for bounded discrete distribution or RealInterval for continuous distribution
  • maximum
  • minimum
  • islowerbounded
  • isupperbounded
  • isbounded

So that one need not to rewrite these boilerplates when implementing a new distribution.

This macro has been successfully applied to all univariate distributions provided in the package.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) when pulling f836759 on dh/support2 into 8184f0d on master.

lindahua added a commit that referenced this pull request Nov 17, 2014
Unify the specification of distribution supports
@lindahua lindahua merged commit 4727048 into master Nov 17, 2014
@johnmyleswhite
Copy link
Member

This is a big improvement. Thanks, Dahua!

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

Successfully merging this pull request may close these issues.

3 participants