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

limit the values of random sampling from the VonMises distribution to -pi ~ +pi #1061

Closed
sosuts opened this issue Jan 25, 2020 · 7 comments
Closed

Comments

@sosuts
Copy link

sosuts commented Jan 25, 2020

I want to limit the values of random sampling from the VonMises distribution to -pi ~ +pi.

I have some circular data which the domain is -pi ~ +pi.
I want to model the data by using Distributions.jl and Turing.jl.
However, the domain of VonMises(mu, kappa) seems to be mu-pi ~ mu+pi.
I could change pdf and cdf to -pi ~ + pi but I couldn't figure out how to change rand.

Which part of VonMisesSampler should be changed...?
Any suggestions are welcomed.
Thank you in advance.

pdf_cdf

hist

@matbesancon
Copy link
Member

Doesn't it work with mu set to 0?

@sosuts
Copy link
Author

sosuts commented Jan 28, 2020

It does, but in other words, it only works with mu set to 0.
I think it would be nice if it work just like np.random.vonmises().
npmu3kappa5

@matbesancon
Copy link
Member

Ok so you mean a by default constructor VonMises()?
The structure of Distributions.jl is more based on constructing the distribution you want and then operating on it
For more explanation on the rational, you can check this preprint
https://arxiv.org/abs/1907.08611

@sosuts
Copy link
Author

sosuts commented Jan 28, 2020

Yes, a default constructor.
I thought I have to fix the domain to use VonMises for Turing.jl.
I could custom pdf and cdf of default constructor and fix the domain to -pi~+pi whatever the mu is.(1st fig, a distribution I constructed)
But I couldn't find how to custom rand method(2nd fig, default VonMises constructor).
I'm not a native English speaker.
I'm so sorry if my sentence doesn't make sense...

Anyway, it seems VonMises is not available for Turing.jl uses.
Just fixing the domain may not solve the problem.
TuringLang/DistributionsAD.jl#2

@matbesancon
Copy link
Member

There is already a default constructor:

VonMises() = VonMises(0.0, 1.0, check_args=false)

@sosuts
Copy link
Author

sosuts commented Jan 28, 2020

Sorry, I was misunderstanding a meaning of default constructor.

Usually, von Mises distribution is used for modelling circular data(domain : 0 ~ 2pi, or -pi ~+pi).
The domain of

VonMises() = VonMises(0.0, 1.0, check_args=false)

is -pi ~ +pi just because mu is 0.
But for example, if you change a value of mu using default definition in Distributions.jl, the domain will change to mu-pi ~ mu+pi.
I made this issue because I want the domain to be -pi ~ +pi whatever the mu is and I don't know how to realize this.
Usually, the domain of mu is set to 0 ~ 2pi or -pi ~+pi just as von Mises distribution itself is.

@sosuts
Copy link
Author

sosuts commented Jan 28, 2020

@matbesancon
I'm so sorry for my confusing English, thank you for answering many times!

@sosuts sosuts closed this as completed Jan 31, 2020
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

2 participants