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

Operations on objects with different element type #93

Open
nathanaelbosch opened this issue Jul 17, 2024 · 2 comments
Open

Operations on objects with different element type #93

nathanaelbosch opened this issue Jul 17, 2024 · 2 comments

Comments

@nathanaelbosch
Copy link
Collaborator

The concrete example I have is a multiplication

[1 0; 0 1] * Normal(rand(2), Symmetric(rand(2,2)))

This does not work right now. I think similar considerations apply to many other functions that are implemented, and they often assume that the element type is exactly the same. Maybe it would be better to let julia handle type promotion etc?

@filtron
Copy link
Owner

filtron commented Jul 19, 2024

I think the problem is that e.g.

*(C::Abstractmatrix{T}, D::AbstractDistribution{T})

is really defined as

marginalize(D, DiracKernel(C))

so the following should not really be allowed (and vice versa):

*(C::Abstractmatrix{<:Real}, D::AbstractDistribution{<:Complex})

I guess an alternative is to simply do:

*(C::AbstractMatrix{<:Real}, D::AbstractDistribution{<:Real}) = marginalize(D, DiracKernel(C))
*(C::AbstractMatrix{<:Complex}, D::AbstractDistribution{<:Complex}) = marginalize(D, DiracKernel(C))

Unless there is a more clever way?

@filtron
Copy link
Owner

filtron commented Jul 19, 2024

The above is too complicated I think just treating e.g. Normal{<:Real} as a Normal{<:Complex} with zero imaginary variance appears the simplest. This would make the following legal:

kldivergence(::Normal{<:Complex}, ::Normal{<:Real})

which is a bit awkward but it is perhaps still fine.

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