Skip to content

LogitNormal code review #2074

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

Closed
denadai2 opened this issue Apr 25, 2017 · 1 comment
Closed

LogitNormal code review #2074

denadai2 opened this issue Apr 25, 2017 · 1 comment

Comments

@denadai2
Copy link
Contributor

Hello everybody,
I would like to write the LogitNormal function (suggested from here #2066) and add it to pymc3 as well, but I have some problems with ADVI which finds NaN. This could be caused by my model, or by this code where I need some help. Sorry to bother
ref: https://en.wikipedia.org/wiki/Logit-normal_distribution

class Logitnormal(PositiveContinuous):

    def __init__(self, mu=0.5, tau=None, *args, **kwargs):
        super(Logitnormal, self).__init__(*args, **kwargs)

        self.mu = mu = tt.as_tensor_variable(mu)
        self.tau = tau = tt.as_tensor_variable(tau)
        
        self.median = logit(mu)
        assert_negative_support(tau, 'tau', 'Logitnormal')

    def logp(self, value):
        mu = self.mu
        tau = self.tau
        return bound(-0.5 * tau * (logit(value) - mu)**2
                     + 0.5 * tt.log(tau / (2. * np.pi))
                     - tt.log(value*(1-value)),value > 0, value <1, tau > 0)
@denadai2 denadai2 changed the title LogitNormal LogitNormal code review Apr 25, 2017
@denadai2
Copy link
Contributor Author

denadai2 commented May 1, 2017

closed in favour to #2100

@denadai2 denadai2 closed this as completed May 1, 2017
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

1 participant