The ChebFun MATLAB package links to a nice Python package called PaCAL
.
This nice package allows doing some arithmetic with random variables / distributions and get and object which basically represents the PDF without sampling.
Behind the scenes it works similarly to the ideas of ChebFun / ApproxFun.jl
.
I was wondering if there is a wrapper around ApproxFun.jl
which allows similar functionality.
With @sethaxen permission, I am writing his answer to a specific problem I raised on Slack.
Specific Example
The random variable b is distributed by b \sim \mathcal{Gamma} \left( \alpha, \beta \right) how could one symbolically represent the variable \frac{a}{b} for a constant a ?
Seth’s Answer
@sethaxen suggested this particular example can be solved using Bijectors.jl
and Distributions.jl
:
using Bijectors, Distributions
d = Gamma(2, 3)
a = 5.0
dtrans_actual = InverseGamma(d.α, inv(d.θ)) * a
bijector = Bijectors.Scale(a) ∘ Bijectors.Exp() ∘ Bijectors.Scale(-1) ∘ Bijectors.Log()
dtrans = Bijectors.transformed(d, bijector)
x = range(quantile(dtrans_actual, [0.01, 0.99])...; length=1000)
logpdf.(dtrans, x) ≈ logpdf.(dtrans_actual, x)
The actual answer on Slack:
Yet, to @sethaxen knowledge, the examples at PaCAL
page currently can not be reproduced in Julia’s eco system.