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

Incorrect implementation of rvs.Triangular.logcdf_x #59

Closed
mahausmani opened this issue Jan 16, 2024 · 1 comment · Fixed by #61
Closed

Incorrect implementation of rvs.Triangular.logcdf_x #59

mahausmani opened this issue Jan 16, 2024 · 1 comment · Fixed by #61
Assignees
Labels
bug Something isn't working

Comments

@mahausmani
Copy link
Contributor

mahausmani commented Jan 16, 2024

Description

the log_cdf function of triangular distribution incorrectly calculates the cdf when x==self_mode:

@partial(jit, static_argnums=(0,))
def logcdf_x(self, x: Numeric) -> Numeric:
    conditions = [
        x < self._low,
        (self._low <= x) & (x < self._mode),
        x == self._mode,
        (self._mode < x) & (x < self._high),
        x >= self._high,
    ]
    choices = [
        -jnp.inf,
        2 * jnp.log(x - self._low) - jnp.log(self._high - self._low) - jnp.log(self._mode - self._low),
        jnp.log(0.5),
        jnp.log(1 - ((self._high - x) ** 2 / ((self._high - self._low) * (self._high - self._mode)))),
        jnp.log(1),
    ]
    return jnp.select(conditions, choices)

it should instead return:

2 * jnp.log(x - self._low) - jnp.log(self._high - self._low) - jnp.log(self._mode - self._low),

What jaxampler version are you using?

nightly

Which accelerator(s) are you using?

CPU

Additional system info?

Linux

NVIDIA GPU info

No response

@mahausmani mahausmani added the bug Something isn't working label Jan 16, 2024
@Qazalbash Qazalbash changed the title Bug in Triangular Distribution: Incorrect implementation of log_cdf Incorrect implementation of rvs.Triangular.logcdf_x Jan 16, 2024
Qazalbash added a commit that referenced this issue Jan 16, 2024
@Qazalbash
Copy link
Owner

@mahausmani thanks for the report, it should be fixed by #61

@Qazalbash Qazalbash self-assigned this Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants