Priors
All parameters to your model must have a prior defined. You may provide any continuous, univariate distribution from the Distributions.jl. A few useful distributions include:
Normal
Uniform
LogNormal
LogUniform
TrucatedNormal
VonMises
This pacakge also defines the Sine()
distribution for e.g. inclination priors and UniformCircular()
for periodic variables. Internally, UniformCircular()
creates two standard normal variables and finds the angle between them using arctan
. This allows the sampler to smoothly cycle past the ends of the domain. You can specify a different circular domain than (0,2pi) by passing the size of the domain e.g. τ = UniformCircular(1.0)
.
The VonMise distribution is notable but not commonly used. It is the analog of a normal distribution defined on a circular domain (-π, +π). If you have a Gaussian prior on an angular parameter, a Von Mises distribution is probably more appropriate.
Behind the scenes, Octofitter remaps your parameters to unconstrained domains using the Bijectors.jl (and corrects the priors accordingly). This is essential for good sampling efficiency with HMC based samplers.
This means that e.g. if you define the eccentricity prior as e=Uniform(0,0.5)
, the sampler will actually generate values across the whole real line and transform them back into the [0,0.5]
range before evaluating the orbit. It is therefore essential that your priors do not include invalid domains.
For example, setting a=Normal(3,2)
will result in poor sampling efficiency as sometimes negative values for semi-major axis will be drawn (especially if you're using the parallel tempered sampler).
Instead, for parameters like semi-major axis, eccentricity, parallax, and masses, you should truncate any distributions that have negative tails. This can easily be accomplished with TrauncatedNormal
or Trunacted(dist, low, high)
for any arbitrary distribution.
Observable Based Priors
Octofitter implements observable-based priors from O'Neil 2019 for relative astrometry. You can fit a model to astrometry using observable-based priors using the following recipe:
using Octofitter, Distributions
astrom_like = AstrometryLikelihood(
(;epoch=mjd("2020-12-20"), ra=400.0, σ_ra=5.0, dec=400.0, σ_dec=5.0)
)
@planet b Visual{KepOrbit} begin
# For using with ObsPriors:
P ~ Uniform(0.001, 1000)
a = cbrt(system.M * b.P^2)
e ~ Uniform(0.0, 1.0)
i ~ Sine()
ω ~ UniformCircular()
Ω ~ UniformCircular()
τ ~ UniformCircular(1.0)
mass ~ LogUniform(0.01, 100)
end astrom_like ObsPriorAstromONeil2019(astrom_like);
@system System1 begin
plx ~ Normal(21.219, 0.060)
M ~ truncated(Normal(1.1, 0.2),lower=0)
end b
model = Octofitter.LogDensityModel(System1, verbosity=4)
LogDensityModel for System System1 of dimension 12 with fields .ℓπcallback and .∇ℓπcallback
octofit(
model, 0.95;
adaptation = 1000,
iterations = 1000,
verbosity = 4,
max_depth = 10,
)
Chains MCMC chain (1000×29×1 Array{Float64, 3}):
Iterations = 1:1:1000
Number of chains = 1
Samples per chain = 1000
Wall duration = 34.5 seconds
Compute duration = 34.5 seconds
parameters = plx, M, b_P, b_e, b_i, b_ωy, b_ωx, b_Ωy, b_Ωx, b_τy, b_τx, b_mass, b_a, b_ω, b_Ω, b_τ
internals = n_steps, is_accept, acceptance_rate, hamiltonian_energy, hamiltonian_energy_error, max_hamiltonian_energy_error, tree_depth, numerical_error, step_size, nom_step_size, is_adapt, loglike, logpost, tree_depth, numerical_error
Summary Statistics
parameters mean std mcse ess_bulk ess_tail rhat ⋯
Symbol Float64 Float64 Float64 Float64 Float64 Float64 ⋯
plx 21.2385 0.0000 0.0000 NaN NaN NaN ⋯
M 0.7599 0.0000 0.0000 NaN NaN NaN ⋯
b_P 266.5555 0.0000 0.0000 NaN NaN NaN ⋯
b_e 0.1861 0.0000 0.0000 NaN NaN NaN ⋯
b_i 2.5847 0.0000 0.0000 NaN NaN NaN ⋯
b_ωy 0.3173 0.0000 0.0000 NaN NaN NaN ⋯
b_ωx 0.9709 0.0000 0.0000 NaN NaN NaN ⋯
b_Ωy -0.4196 0.0000 0.0000 NaN NaN NaN ⋯
b_Ωx 0.9454 0.0000 0.0000 NaN NaN NaN ⋯
b_τy 1.0201 0.0000 0.0000 NaN NaN NaN ⋯
b_τx 0.0233 0.0000 NaN NaN NaN NaN ⋯
b_mass 0.3185 0.0000 0.0000 NaN NaN NaN ⋯
b_a 37.7961 0.0000 0.0000 NaN NaN NaN ⋯
b_ω 1.2549 0.0000 0.0000 NaN NaN NaN ⋯
b_Ω 1.9885 0.0000 0.0000 NaN NaN NaN ⋯
b_τ 0.0036 0.0000 0.0000 NaN NaN NaN ⋯
1 column omitted
Quantiles
parameters 2.5% 25.0% 50.0% 75.0% 97.5%
Symbol Float64 Float64 Float64 Float64 Float64
plx 21.2385 21.2385 21.2385 21.2385 21.2385
M 0.7599 0.7599 0.7599 0.7599 0.7599
b_P 266.5555 266.5555 266.5555 266.5555 266.5555
b_e 0.1861 0.1861 0.1861 0.1861 0.1861
b_i 2.5847 2.5847 2.5847 2.5847 2.5847
b_ωy 0.3173 0.3173 0.3173 0.3173 0.3173
b_ωx 0.9709 0.9709 0.9709 0.9709 0.9709
b_Ωy -0.4196 -0.4196 -0.4196 -0.4196 -0.4196
b_Ωx 0.9454 0.9454 0.9454 0.9454 0.9454
b_τy 1.0201 1.0201 1.0201 1.0201 1.0201
b_τx 0.0233 0.0233 0.0233 0.0233 0.0233
b_mass 0.3185 0.3185 0.3185 0.3185 0.3185
b_a 37.7961 37.7961 37.7961 37.7961 37.7961
b_ω 1.2549 1.2549 1.2549 1.2549 1.2549
b_Ω 1.9885 1.9885 1.9885 1.9885 1.9885
b_τ 0.0036 0.0036 0.0036 0.0036 0.0036