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

Lack of Half-Cauchy distribution #100

Closed
sharanry opened this issue Jul 7, 2018 · 5 comments
Closed

Lack of Half-Cauchy distribution #100

sharanry opened this issue Jul 7, 2018 · 5 comments

Comments

@sharanry
Copy link

sharanry commented Jul 7, 2018

Half-Cauchy distribution is a requirement for the well known centered eight schools model.

pymc4 issue: pymc-devs/pymc4#12

@davmre
Copy link
Contributor

davmre commented Jul 12, 2018

Half-Cauchy is a common prior, so it'd be great to have this explicitly. The implementation should be fairly straightforward, following the half-normal distribution.

As a workaround, in defining log-densities for inference you can generally also just use the Cauchy density, assuming you're already using variable transformations to constrain your inferences to be positive (which typically has nicer properties than just relying on -inf's in the log density).

@jvdillon
Copy link
Contributor

How about:

class HalfCauchy(tfp.distributions.TransformedDistribution):
  def __init__(self, loc, scale, validate_args=False):
    super(HalfCauchy, self).__init__(
        distribution=tfp.distributions.Cauchy(loc, scale, validate_args=validate_args),
        bijector=tfp.bijectors.AbsoluteValue(validate_args=validate_args))

@davmre
Copy link
Contributor

davmre commented Jul 15, 2018

Wouldn't you need to apply the AbsoluteValue in a standardized space? Something like,

bijector = tfp.bijectors.Chain([
    tfp.bijectors.AffineScalar(shift=loc),
    tfp.bijectors.AbsoluteValue(),
    tfp.bijectors.AffineScalar(shift=-loc)])

@jvdillon
Copy link
Contributor

Yes, but the problem is that Chain doesnt know how to work with non-injective bijectors such as AbsoluteValue. It might be possible to add this capability, and if so would be a very nice improvement.

In my comment, I should have indicated that this isnt HalfCauchy but should have the desired similar properties, esp if all you need is a prior.

@srvasude
Copy link
Contributor

FYI, we have a PR for this internally coming soon.

@csuter csuter closed this as completed in be36a01 Sep 19, 2018
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

No branches or pull requests

4 participants