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

Type instability whenever calling randexp #1527

Closed
enweg opened this issue Apr 1, 2022 · 1 comment
Closed

Type instability whenever calling randexp #1527

enweg opened this issue Apr 1, 2022 · 1 comment

Comments

@enweg
Copy link

enweg commented Apr 1, 2022

rand(rng::AbstractRNG, d::Exponential) = xval(d, randexp(rng))

I have noticed that even when declaring Gamma, Exponential and similar distributions to be of type Float32, sampling always returns a Float64. Not sure if this is intentional or not, but it seems to be easily fixed by always calling randexp(rng, T) with T being the type of the parameters of the distribution.

Would be interested to know if this was intentional? It does not seem like it to me given that rand will return Float32 for gaussians of type Float32.

@devmotion
Copy link
Member

Yes, this is intentional (BTW usually type instability refers to functions for which the type can't be inferred which is not the case here). There are some open issues (#1071) and a PR that would fix current inconsistencies (#1433). Unfortunately, there are some issues with dual numbers and I didn't have much time lately, but I hope I (or someone else) can pick it up and fix the remaining issues in the near future.

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