You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed type instabilities when dealing with mixtures of distributions of different types. For example, the following mixture of a Dirac and a (shifted) Geometric distribution (both discrete), which I need for my work, has a type instability for evaluating the pdf and sampling a single random variate. Interestingly, sampling multiple random numbers (e.g., rand(d, 10) or even rand(d, 1)) is type stable.
using Distributions
a =0.2
b =0.95
d1 =Dirac(0)
d2 =Geometric(1-b) +1
d =MixtureModel([d1, d2], [a, 1-a])
@code_warntypepdf(d, 2) # type instable@code_warntypepdf.(d, [2,3,4]) # type instable@code_warntyperand(d) # type instable@code_warntyperand(d, 1) # type STABLE (?)
The properties of the mixtures seem correct; the pdfs look fine and also mean numbers make sense. But the type instability currently slows down my code.
The issue is not restricted to this specific setup. Also a mixture of Poisson and (not shifted) Geometric distributions has the same issues. The instability vanishes if d1 and d2 have the same distribution type (e.g., both Geometric) (as discussed on Discourse). Mixtures of continuous distributions (e.g., exponential and normal) also seem to have this issue.
It was unclear to us whether this can be considered a bug or missing feature.
Any help greatly appreciated!
Julia Version 1.10.4
Distributions v0.25.107
The text was updated successfully, but these errors were encountered:
Hi all,
I noticed type instabilities when dealing with mixtures of distributions of different types. For example, the following mixture of a Dirac and a (shifted) Geometric distribution (both discrete), which I need for my work, has a type instability for evaluating the pdf and sampling a single random variate. Interestingly, sampling multiple random numbers (e.g.,
rand(d, 10)
or evenrand(d, 1)
) is type stable.The properties of the mixtures seem correct; the pdfs look fine and also mean numbers make sense. But the type instability currently slows down my code.
The issue is not restricted to this specific setup. Also a mixture of Poisson and (not shifted) Geometric distributions has the same issues. The instability vanishes if
d1
andd2
have the same distribution type (e.g., both Geometric) (as discussed on Discourse). Mixtures of continuous distributions (e.g., exponential and normal) also seem to have this issue.It was unclear to us whether this can be considered a bug or missing feature.
Any help greatly appreciated!
Julia Version 1.10.4
Distributions v0.25.107
The text was updated successfully, but these errors were encountered: