PolyaGammaHybridSamplers
Documentation for PolyaGammaHybridSamplers.
PolyaGammaHybridSamplers.PolyaGammaHybridSamplerPolyaGammaHybridSamplers.rand_pgdevroyePolyaGammaHybridSamplers.rand_pggammasumPolyaGammaHybridSamplers.rand_pgnormalapproxPolyaGammaHybridSamplers.rand_pgsaddlepoint
PolyaGammaHybridSamplers.PolyaGammaHybridSampler — TypePolyaGammaHybridSampler(b::Real, z::Real, [method::PGSamplingMethod])A sampler for the Polya-Gamma distribution using a hybrid of the saddlepoint approximation, the Devroye method, the normal approximation, and the sum of gammas approximation, each of which are discussed in Windle et al. (2014) – see README.md for details.
Arguments
b::Real: The shape parameter of the Polya-Gamma distribution. Must be positive.z::Real: The exponential tilting parameter of the Polya-Gamma distribution.method::PGSamplingMethod : An Enum object specifying the method used to sample from the Polya-Gamma distribution. Must be one ofDEVROYE,SADDLEPOINT,NORMALAPPROX,GAMMASUM, orDEVROYEPLUSGAMMASUM. If omitted, the method is chosen automatically based on the value ofb`.
Returns
- A
PolyaGammaHybridSamplerobject which can be sampled usingrandorrand!.
Examples
julia> using PolyaGammaHybridSamplers
julia> s = PolyaGammaHybridSampler(1, 1.0)
julia> rand(s)Notes
- Automatic selection criteria:
b > 170->NORMALAPPROXb >= 13->SADDLEPOINTb >= 1 && isinteger(b)->DEVROYEb > 1 && !isinteger(b)->DEVROYEPLUSGAMMASUMb >= 0->GAMMASUMb = 0-> degenerate distribution at 0
PolyaGammaHybridSamplers.rand_pgdevroye — Methodrand_pgdevroye(b::Integer, z::Real, [rng::AbstractRNG = Random.default_rng()]])Sample from a Polya-Gamma distribution using the Devroye method.
Arguments
b::Integer: the shape parameterz::Real: the exponential tilting parameterrng::AbstractRNG: optional random number generator object forrand
Returns
- A sample from the Polya-Gamma distribution with shape parameter
band exponential tilting parameterz.
Notes
- This method is exact, but is increasingly slower as
bincreases. - This sampler requires integer
b. - Automatically selects the method when
b < 13and is an integer.
PolyaGammaHybridSamplers.rand_pggammasum — Methodrand_pggammasum(b::Real, z::Real, [rng::AbstractRNG = Random.default_rng()])Sample from a Polya-Gamma distribution using the truncated sum of gammas representation.
Arguments
b::Real: the shape parameterz::Real: the exponential tilting parameterrng::AbstractRNG: random number generator object forrand
Returns
- A sample from the Polya-Gamma distribution with shape parameter
band exponential tilting parameterz.
Notes
- This method supports non-integer
bbut is only an approximation, meant only for b < 1 - No warning is given if
bis too large. - The sum is truncated to 200 terms according to the paper's recommendation.
- Automatically selects this method when
b < 1or when used in combination with the devroye method for non-integerb.
PolyaGammaHybridSamplers.rand_pgnormalapprox — Methodrand_pgnormalapprox(b::Real, z::Real, [rng::AbstractRNG = Random.default_rng()])Sample from a Polya-Gamma distribution using the normal approximation method.
Arguments
b::Real: the shape parameterz::Real: the exponential tilting parameterrng::AbstractRNG: random number generator object forrand
Returns
- A sample from the Polya-Gamma distribution with shape parameter
band exponential tilting parameterz.
Notes
- This method is an approximation that supports non-integer
band is very efficient for largeb. - Automatically selects this method when
b >= 170.
PolyaGammaHybridSamplers.rand_pgsaddlepoint — Methodrand_pgsaddlepoint(b::Real, z::Real, [rng::AbstractRNG = Random.default_rng()])Sample from a Polya-Gamma distribution using the saddlepoint approximation method.
Arguments
b::Real: the shape parameterz::Real: the exponential tilting parameterrng::AbstractRNG: random number generator object forrand
Returns
- A sample from the Polya-Gamma distribution with shape parameter
band exponential tilting parameterz.
Notes
- This method is an approximation that supports non-integer
band is quite efficient for largeb. - Automatically selects this method when
b >= 13.