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

von Mises distribution fails for kappa=0 #564

Closed
mbrubake opened this issue Jun 21, 2017 · 4 comments · Fixed by #1551
Closed

von Mises distribution fails for kappa=0 #564

mbrubake opened this issue Jun 21, 2017 · 4 comments · Fixed by #1551
Labels
Milestone

Comments

@mbrubake
Copy link
Member

Summary:

The von Mises distribution returns a non-finite value when kappa=0. This should result in a uniform distribution and likely needs to be special cased.

Reproducible Steps:

The following model should produce a uniform distribution of test_var but instead, fails at initialization:

parameters {
    real test_var;
}
model {
    test_var ~ von_mises(0,0);
}

Current Output:

Initialization between (-2, 2) failed after 100 attempts. 
 Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.

Expected Output:

Should sample easily and produce a uniform distribution on test_var.

Current Version:

v2.15.0

@mbrubake mbrubake added the bug label Jun 21, 2017
@bob-carpenter bob-carpenter added this to the 2.17 milestone Jun 21, 2017
@bgoodri
Copy link
Contributor

bgoodri commented Jun 21, 2017 via email

@bob-carpenter
Copy link
Contributor

@bgoodri Is it a branch that you could turn into a pull request for this issue? If not, is it a public branch?

@bgoodri
Copy link
Contributor

bgoodri commented Jun 21, 2017 via email

@seantalts seantalts modified the milestones: 2.17.0, 2.17.0++ Sep 6, 2017
@syclik syclik modified the milestones: 2.18.0, 2.18.0++ Feb 13, 2018
@syclik syclik modified the milestones: 2.19.0, 2.19.0++ Mar 18, 2019
@mcol
Copy link
Contributor

mcol commented Dec 21, 2019

The example model now produces the following error (repeated 100 times for each chain):

Chain 1 Exception: von_mises_lpdf: Scale parameter is 0, but must be > 0!

If I remove the check_positive_finite line for kappa, then CmdStan reports:

Exception initializing step size.
Posterior is improper. Please check your model.

which is correct, I think, as test_var would be distributed uniformly over all reals. Changing the model to the following, it samples correctly:

parameters {
  real<lower=-5, upper=5> test_var;
}
model {
  test_var ~ von_mises(0,0);
}

So, am I correct in thinking that @bgoodri's changes to the Bessel functions has effectively fixed this (modulo the overly stringent check on kappa)?

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

Successfully merging a pull request may close this issue.

7 participants