JuliaStats / Distributions.jl

A Julia package for probability distributions and associated functions.
Other
1.08k stars 410 forks source link

Characteristic function for Univariate Mixtures #1838

Open tlamadon opened 4 months ago

tlamadon commented 4 months ago

I would like to suggest adding this method to compute the characteristic function of Univariate Mixtures:

function cf(d::UnivariateMixture,t)
    p = probs(d)
    m = sum(pi * cf(component(d, i),t) for (i, pi) in enumerate(p) if !iszero(pi))
    return m
end

This is a simple copy of the mean function but applied to the characteristic function. So I think it could be added next to it: https://github.com/JuliaStats/Distributions.jl/blob/c1705a3015d438f7e841e82ef5148224813831e8/src/mixtures/mixturemodel.jl#L173

It matches the general cf signature as seen here: https://github.com/JuliaStats/Distributions.jl/blob/c1705a3015d438f7e841e82ef5148224813831e8/src/univariates.jl#L293-L297