WorksPhysics and Astronomy
periapsis: A Comprehensive Orbital Fitting Package
Abstract
We introduce a new Python package periapsis, which computes posterior distributions for a variety of orbital parameters given astrometric and/or radial velocity data. periapsis not only returns posterior distributions, but also a variety of statistics assessing convergence and fit metrics as well as plotting capabilities for visualizing the orbital systems. In this paper, we describe our various methods for fitting Keplerian orbits to both astrometric and radial velocity data. We then show the breadth of binary systems that periapsis can characterize by comparing our computed parameters with known orbital systems. Finally, we discuss how periapsis will be a helpful tool for future data releases like Gaia DR4 and Roman.
Introduction
A large fraction of stars along the main sequence are believed to form and reside in binary or higher-order systems [43] (Moe & Di Stefano 2017). These systems are rich with interesting astrophysical phenomena enabling us to learn more about stellar evolution (Moe & Di Stefano 2017), compact object formation and populations (Andrews et al. 2019; Müller-Horn et al. 2026a), planetary systems (Butler et al. 2006), progenitors to gravitational wave sources (Abbott et al. 2016), and much more. The last few decades of astronomy have seen a dramatic increase in the number of spectroscopic surveys, providing a large number of radial velocity measurements on stars across the Milky Way (De Silva et al. 2015; Majewski et al. 2017), and with the advent of Gaia, astrometry for over a billion sources has been recorded (Gaia Collaboration et al. 2023; Halbwachs et al. 2023). These datasets have led to the discovery of many interesting stellar, planetary, and compact object companions, greatly increasing our knowledge on their populations (Müller-Horn et al. 2026b; Butler et al. 2006; El-Badry et al. 2023a,b; Gaia Collaboration et al. 2024; Whitaker et al. 2026). Being able to accurately characterize these systems and their uncertainties is important to further our understanding of these populations and phenomena.
Many different approaches have been taken to characterize binary systems, with Bayesian inference being highly favored to obtain posterior distributions of orbital parameters that encapsulate their uncertainties (Lucy 2018). Different ways of doing this have been presented in a variety of orbital fitting packages and custom made codes, made to fit astrometry, radial velocity, or joint measurements (Price-Whelan et al. 2017; Blunt et al. 2020a; El-Badry et al. 2024). However, it can be difficult to find a package that works for a variety of observational scenarios and that is easy and intuitive to use.
We here present our comprehensive orbital fitting package periapsis1, which is capable of fitting orbits to a wide variety of observational data, whether that be 2D astrometry, scanning-plane astrometry (like Gaia), radial velocities, or any combination of all three. The package can also accommodate the case where both components of the binary system have been observed, performing a joint fit on both. The package has been designed to fully characterize a binary system with a minimal amount of manual tuning done by the user. This “plug and play” design allows for easy analyses of interesting systems, where users can obtain detailed orbital constraints on their system with a minimal amount of code. The package can return a large variety of statistics on the behavior of the sampler and the parameter values and uncertainties. To visualize the orbital fit and the sampler behavior, multiple plotting options are included.
The rest of the paper is presented as follows. § 2 presents the orbital models used to calculate model positions and velocities, as well as the formulation of other parameters and quantities that are able to be fit for and returned. § 3 then describes the full fitting algorithm, going over the full pipeline from data input to results. We then show the effectiveness of periapsis by fitting known orbital systems in § 4. We conclude with a discussion in § 5.
© 2026 The Authors featuring tips on how to obtain a quick orbital solution and outlook on future uses of the package.
Keplerian Models
Here we describe how we fit a Keplerian orbital model to multi-epoch astrometry data, radial velocity measurements, and joint datasets combining the two. While our model uses a primary set of fitting parameters, periapsis supports sampling for many different orbital parameterizations, which can then be transformed into the inputs required by our model. A full list of supported parameters can be found in Table A1, while any relationship between parameters not presented in this section can be found in Appendix § 8. We also detail the linearization of the Keplerian model, separating the non-linear parameters (period , eccentricity , and time of periastron passage ) from the remaining linear ones (§ 2.3). The remaining parameters can then be solved analytically with our dynamic, observation-defined matrix. Then, § 2.4 describes all the additional parameters that can be incorporated to our models for sampling.
| Description / Name | Parameter | Code Notation | Core |
| Orbital period | P | ✓ | |
| Eccentricity | e | ✓ | |
| Time of periastron passage | Tp | ✓ | |
| Semi-major axis (rel., 1, 2) | a, a1, a2 | ||
| Inclination | i | ||
| Cosine of inclination | cosi | ||
| Sine of inclination | sini | ||
| Argument of periastron (rel., 1, 2) | omega, omega1, omega2 | ||
| Longitude of the nodes | Omega, Omega1, Omega2 | ||
| Longitude of the ascending node | Omega_asc | ||
| Parallax | parallax | ✓ | |
| Astrometric reference offsets | dalpha, ddelta | ✓ | |
| Proper motions | mu_alpha, mu_delta | ✓ | |
| Proper motion accelerations | dmu_alpha, dmu_delta | ||
| Thiele-Innes constants A (rel., 1, 2) | A, A1, A2 | ✓ | |
| Thiele-Innes constants B (rel., 1, 2) | B, B1, B2 | ✓ | |
| Thiele-Innes constants C (rel., 1, 2) | C, C1, C2 | ||
| Thiele-Innes constants F (rel., 1, 2) | F, F1, F2 | ✓ | |
| Thiele-Innes constants G (rel., 1, 2) | G, G1, G2 | ✓ | |
| Thiele-Innes constants H (rel., 1, 2) | H, H1, H2 | ||
| Thiele-Innes velocity constants c (rel., 1, 2) | c, c1, c2 | ✓ | |
| Thiele-Innes velocity constants h (rel., 1, 2) | h, h1, h2 | ✓ | |
| RV semi-amplitude (rel., 1, 2) | K, K1, K2 | ||
| Systemic radial velocity | gamma | ✓ | |
| Linear RV trend | dgamma | ||
| Total system mass | Mtot | ||
| Component masses (body 1, 2) | M1, M2 | ||
| Mass ratio () | q | ||
| Mass function (body 1, 2) | f1, f2 | ||
| Minimum component masses | minM1, minM2 | ||
| Flux ratio | f_band | ||
| Jitter term | astro-jitter, astro-instrument-jitter, rv-jitter, rv-instrument-jitter | ||
| Instrument offset | astro-instrument-offset, rv-instrument-offset, astro-instrument_x_offset, astro-instrument_y_offset | ||
| Reference epoch | Tepoch | ✓ | |
| Semi-minor axis (rel., 1, 2) | b, b1, b2 | ||
| Semi-latus rectum (rel., 1, 2) | p, p1, p2 | ||
| Apoapsis distance (rel., 1, 2) | r_a, r_a1, r_a2 | ||
| Periapsis distance (rel., 1, 2) | r_p, r_p1, r_p2 | ||
| Longitude of periastron (rel., 1, 2) | piomega, piomega1, piomega2 | ||
| Mean motion | n | ||
| Scaled time of periastron passage () | t0 | ||
| Mean anomaly at reference epoch | M0 | ||
| Mean longitude at reference epoch | L0 | ||
| Eccentric anomaly at reference epoch | E0 | ||
| True anomaly at reference epoch | nu0 | ||
| True longitude (epoch, body 1, 2) | l0, l01, l02 | ||
| Gravitational parameter | mu | ||
| Distance | distance |
Table A1. Complete table of parameters for periapsis. The Core column indicates parameters solved analytically via linear least squares or sampled directly in the standard model by default. Italicized text in the Code Notation column represents input by the user.
Unless specified otherwise, parameters presented with a subscript 1 correspond to the more luminous companion, while a subscript 2 corresponds to the less luminous or unseen companion. In practice, the assignments of system 1 and 2 are arbitrary, and the user must be sure to consistently assign them in the data class (§ 3.1).
Astrometry
Astrometric observations are assumed to be defined relative to a reference point with the Right Ascension offset (for small offsets) and Declination offset of the source. The path of the source will show periodic astrometric variations when undergoing Keplerian orbital motion if there is more than one body in the system. The motion of the observer induces additional changes. periapsis is capable of modeling this motion for resolved and unresolved binary systems. The displacement of a source due to parallax , proper motion , and orbital motion is given, for each observational epoch , as
where and give the proper motions, and , where is a conveniently defined reference epoch. The terms and are time dependent parallax factors, which project the Earth’s orbit about the barycentre of the Solar System onto the sky plane, normalized to unity (McArthur et al. (2011), see equations 53 & 54 in Wright & Howard (2009)). , , , are the Thiele-Innes elements, transformations of four of the Campbell elements: semi-major axis , inclination , argument of periastron and longitude of the nodes (see Appendix § 8.1).
We define the argument of periastron in the standard astrometric convention (Lucy 2014), where it is measured from the ascending node in the direction of orbital motion. We define system-specific components and and whose values correspond to the respective component’s orbit with respect to the barycentre. This ensures our definition is fully consistent between astrometry and radial velocity models. When fitting pure astrometry data, the line of sight orientation determined by the sign of inclination is unconstrained. This causes the astrometric fit to be invariant under phase shifts of and , which can only be fully constrained with additional radial velocity data. The longitude of the ascending node can also be fully constrained from joint fits.
The terms and represent the elliptical coordinates in the orbital plane per epoch, which depend on the non-linear parameters , , :
where is the eccentric anomaly obtained by solving Kepler’s equation,
While relative sky-plane astrometry directly measures an instantaneous 2D positional offset, absolute astrometry scanning space missions like Gaia precisely measure the abscissa of the star along a scan direction while the orthogonal axis is determined with much lower precision. For each observation epoch , Gaia records an along scan measurement projected along the instrument scan angle . To evaluate the likelihood for this model, we project onto the scan angle:
Where is the Gaia reported along-scan parallax factor per epoch, which is related to the parallax factors in Equations (1) and (2) by .
Radial Velocities
RV measurements are expected as a time series of the barycentric radial velocity at times . For a system undergoing Keplerian motion, we model the line of sight (radial) velocity as
Here, is the radial velocity semi-amplitude, is the barycentric systemic velocity and is the true anomaly given by
To separate the linear parameters, we use a slightly different model where
Here and are constants closely related to the Thiele-Innes elements and (Wright & Howard 2009), and are given by
Throughout this paper, always refers to the definition given in Equation (11), not the speed of light. In the case that both systems are observed or enough information is obtained to define both, Equation (7) or Equation (9) is solved for both systems 1 and 2 with their unique components .
Linearization
The parameter vectors corresponding to the models presented in § 2.1 and 2.2 can be sampled in full by periapsis. However, the linear parameters can also be separated from the non-linear ones, allowing us to sample just , , and . This method is widely used, as it reduces the dimensionality of the sampling space, leading to faster convergence and improved computational efficiency ((Wright & Howard 2009; Lucy 2014; El-Badry et al. 2024)).
We follow the linearization procedure from El-Badry et al. (2024), but generalize it to the non-Gaia case, where astrometry is defined as and as above, and incorporating RVs. Given a proposed , and , the linear parameters can be solved analytically via linear least squares. We start by writing:
where is the vector of observational data, is the design matrix, and is the linear parameter vector. Consider a case where both relative astrometry and RVs are available. The data vector and linear parameter vector take the form:
and the dynamic design matrix is constructed as a block matrix:
where the astrometric sub-matrix operating on is given by:
and the radial velocity sub-matrix operating on is given by:
In the case of 1D Gaia astrometry, the astrometric rows are projected along the instrument scan angle, resulting in matrix given in Appendix A of El-Badry et al. (2024).
The maximum likelihood solution for the linear parameter vector is then evaluated at each sampling step via weighted linear least squares:
where the observational uncertainties are taken into account with the inverse covariance matrix .
Systemic Trends, Mass Functions, and Null Hypothesis Models
In addition to pure Keplerian orbital motion, periapsis can account for instrumental offsets, long-term RV trends, flux ratios, jitter, physical mass constraints, and null hypothesis fitting. Here, we present how each of these are incorporated into our framework.
Instrumental Offsets and Acceleration Trends
When combining observations from multiple instruments, potential offsets between the instrumental reference frames can be accounted for. For each instrument provided, an instrumental offset term can be added linearly to the corresponding model. For example, if multiple instruments are used for radial velocity measurements, then an offset term for each telescope will be linearly added to Equation (7) relative to a chosen reference frame.
Additionally, to account for acceleration caused by long-period companions, one can fit for a linear radial velocity trend ((Wright & Howard 2009)) by adding to Equation (7). Astrometric acceleration can be accounted for through the parameters , by adding , to Equations (1) and (2), respectively.
Both the instrumental offsets and the acceleration trend parameters can be incorporated with our linear model (§ 2.3) by simply including these terms in the parameter vector . Their corresponding elements in the sub-matrices ( and ) are dynamically populated with 1 for specified instrumental offsets, is populated with for , and is populated with for the astrometric acceleration parameters.
Flux Ratios
In the case that both bodies in an unresolved astrometric binary are luminous, the photocentre will no longer trace a single star, but will fall on a line between the two bodies. The photocentre semimajor axis is given as
where the mass ratio , is the primary’s semimajor axis, and is the flux ratio. and correspond to flux from the primary and secondary companions, respectively. The filter for the flux is provided by the user in the data class (§ 3.1), and a flux ratio can be fit for each filter in the data set. This is applied to our model by multiplying the photocentre factor to the Thiele-Innes elements , , , . will be consistent with zero when the system contains a dark companion and systematic-free astrometry ((El-Badry et al. 2026)).
Jitter
Astrometry and radial velocity measurements may show higher variance than expected from instrumental uncertainties alone due to unmodeled stellar activity and additional instrument systematics ((Baluev 2009; Taaki et al. 2026)). To account for this, periapsis can fit for a jitter term by defining the total variance as
The log-likelihood for observations is then modified to incorporate in place of :
where the errors are assumed to be Gaussian and uncorrelated.
Mass Constraints
Different constraints on the masses of the binary components can be made depending on the type of observation made. RV observations are inherently limited to measuring the minimum masses due to the unknown inclination angle , while astrometry can provide constraints on the inclination directly.
We infer dynamical mass estimates through Kepler’s third law, combining the orbital period with the physical semi-major axis. This is done in the canonical unit system (§ 3.1) such that the gravitational constant . Angular astrometric semi-major axes are converted to physical units using the parallax, .
For cases where both components of the system have been observed, the mass ratio can be determined with
Radial velocity data specifies the RV primary mass function
which constrains the minimum mass of the secondary (for the case where and , giving ). The analogous is defined by and constrains the minimum mass of the primary.
Assuming a visible primary and an invisible secondary, the astrometric mass function for the unseen companion is given as
If the primary mass is known (Andrews et al. (2019)), the companion mass or its minimum can be uniquely determined, for the astrometric and RV cases, respectively. Both Equations (23) and (22) are then solved numerically for each posterior sample to obtain and .
Null Hypothesis Models
To check whether a Keplerian orbit is truly the best descriptor of the observed data, one can compare the of the orbital fit with a single star null hypothesis fit.
The single star model for astrometry is modeled as
While the single star model for astrometry is
For radial velocities, the null model simply fits a constant systemic velocity .
These models are all fit via linear least squares to obtain a quick estimate on the of the single star model. The difference between the single star fit and the full Keplerian fit is used to create parameter grids to obtain initial estimates for seeding the sampler (§ 3.3) and reported at the end of fitting (§ 3.5).
periapsis Fitting Algorithm
periapsis uses Bayesian inference to infer a posterior probability distribution for the orbital parameters and companion properties from multiple types of observations, such as 2D relative astrometry, 1D scan-plane astrometry, radial velocities. It has been made to require minimal manual configuration by the user while providing a streamlined pipeline that handles unit normalization, parameter initialization, posterior sampling, statistical analysis, and scientific visualization.
As illustrated in Figure 1, the package’s workflow proceeds in the following steps:
Figure 1. Flowchart of the periapsis orbital parameter estimation framework.
Data Input: Observational measurements, errors and their corresponding units are ingested and converted into package’s canonical unit system (§ 3.1).
Priors: Users can define prior probability distributions over both sampled and derived physical parameters. Uniform, normal, beta, log-uniform, and log-normal distributions are directly supported (§ 3.2).
Initial Guesses: Sampling with emcee (Foreman-Mackey et al. (2013)) requires an initial seed to start exploration of the parameter space. Multiple initial fitting schemes are offered depending on the observational data supplied to efficiently locate a plausible global minima within the parameter space to seed the sampler (§ 3.3).
Sampling: To fit a Keplerian orbit to the input data, periapsis utilizes Bayesian posterior sampling to determine the orbital parameters. Two sampling methods are offered for Bayesian inference with either the Markov Chain Monte Carlo (MCMC) technique via emcee (Foreman-Mackey et al. (2013)), or Nested Sampling via UltraNest (Buchner (2021)) (§ 3.4).
Output: Once sampling is completed, periapsis returns the posterior distribution for sampled and derived physical parameters. It can then provide a variety of statistics discussing the fit properties and sampler convergence, as well as visualizations for the sampler characteristics and orbital fit (§ 3.5).
Data and Unit Initialization
Provided data and its corresponding units are input and ingested through the package’s data classes AstrometryData, RadialVelocityData and GaiaData. periapsis uses astropy.units (Astropy Collaboration et al. (2013, 2018, 2022)) to parse the supplied units and ensure that quantities within each dataset are dimensionally compatible. This allows users to provide data in any standard astronomical unit without manual conversion before fitting.
The user must provide units for their data. All quantities are then converted into a canonical unit system upon ingestion. The assumed canonical units are years for time, astronomical units for linear distances, radians for angular quantities, AU/yr for linear velocities, and solar masses for mass. In the canonical unit system, the gravitational constant .
The dimensionality and original unit for each quantity is saved throughout the analysis, where the modeled and derived parameters are calculated in the canonical unit system, and output in the user specified units. A parallax or distance is needed to convert from angular astrometric quantities to physical linear quantities.
Users must specify which system component their data corresponds to in the data class by setting the system to either ‘relative’, ‘1’ or ‘2’. This allows periapsis to correctly define parameters and model the motion for each individual component. The filter and instrument corresponding to each data can also be supplied in the data classes, which are then taken to make a variable for an instrumental offset parameter (§ 2.4.1) and flux ratio (§ 2.4.2) if those parameters are desired to be fit. Any number of data classes can be constructed and put into the JointData class, which will then fit all supplied datasets with a joint likelihood. This allows for joint fits between radial velocity and astrometry measurements, multiple instruments, and enables a way to fit for both components of the binary system if both have been observed.
Priors
Inputted priors are what define the parameters desired for sampling. The amount of parameters supplied must define enough parameters to model the provided data (§ 2.1, 2.2), or in the case of linearization (§ 2.3), only the non-linear parameters , , must have specified priors (or parameters that can transform to them).
If no units are provided for prior values, they are expected to be input with the units used in the data class, meaning that if a user supplied their observation times in years, then a prior on period would be in units of years. The priors are then converted into the canonical unit system for internal calculations. Unit conversion is a linear transformation, which has no impact on sampling or convergence. This is because emcee is affine invariant ((Foreman-Mackey et al. 2013)) and UltraNest maps the parameter space to a unit hypercube ((Buchner 2021)).
periapsis offers supported prior probability distributions for both sampled and derived physical parameters. Standard uniform (UniformPrior), normal (NormalPrior) and beta (BetaPrior) distributions are offered, along with log counterparts (LogUniformPrior and LogNormalPrior).
For derived parameters, we offer a Bounds prior class, which simply sets the bounds on a derived parameter. For example, if you know your data set does not contain any binary with a companion mass , a bound is set on the derived companion mass , meaning any sample that has an outside the bounds is rejected. The FixedPrior class is offered to allow users to fix parameters, like setting for known circular orbits. This is also the standard way to set a known primary mass and a reference epoch .
UltraNest requires priors to be transformed to a unit hypercube. periapsis handles this by automatically transforming the provided priors, allowing users to seamlessly switch between emcee and UltraNest with a single set of priors.
Determining Initial Guesses
To implement emcee, one must first provide an initial guess to the sampler. The initial estimated parameters can significantly impact the performance and accuracy of MCMC. Initial guesses far from the correct solution can result in posteriors getting stuck in local minima. We find that if the sampler has a decent estimate on the period of the orbital system, the time to convergence is significantly decreased and getting trapped in local minima is less likely. We introduce multiple initial fitting schemes that are unique to the types of data that one is performing an orbital fit on.
In this section, we first detail the specific periodogram framework used to find an initial period estimate on different data types. We then describe how we obtain an initial estimate for the remaining parameters to provide a robust walker seed for emcee.
2D Astrometry
To determine an initial period estimate from irregularly sampled time series, the package utilizes the Lomb-Scargle (LS) (Lomb 1976; Scargle 1982; VanderPlas 2018) implementation in astropy to evaluate power spectra along both orthogonal axes. The spectra are then added into a combined spectrum, where a specified number of peaks from the combined power yields the primary candidate frequencies, whose inverse are the candidate estimates. The amount of peaks selected for candidate frequencies by default is one, but the user is free to specify any number of peaks in the emcee fitter classes with the npeaks argument (§ 3.4.1).
The sensitivity of the LS periodogram can degrade in high eccentricity regimes due to transfer of spectral power from the fundamental frequency into higher order harmonics. However, for astrometry the power fraction in the fundamental frequency remains above 80% (Delisle & Ségransan 2022). While other methods have been developed to model the periodicity in high eccentricity regimes (Zucker 2019; Delisle & Ségransan 2022), the high computational efficiency of the LS algorithm and the minor fractional power loss makes the LS periodogram well suited for seeding the initialization pipeline.
The LS fit also provides a heuristic estimate on the semimajor axis . By taking the best-fitting trigonometric amplitudes associated with the primary candidate frequency along each axis (), the spatial extent of the orbit can be estimated by combining the amplitudes in quadrature,
Although this estimate does not take into account the inclination or spatial orientation, it provides an appropriate order of magnitude constraint for the spatial scale of the system.
Gaia Astrometry
Since Gaia measurements are projected along a scan angle, the sinusoidal periodicity that Lomb-Scargle is based upon is no longer effective at determining an accurate period. To obtain an initial period estimate for Gaia data, we implement the general linear periodogram approach developed by Delisle & Ségransan (2022) for scanning space astrometry.
We start by creating a grid of trial frequencies , whose range is determined by the users provided prior on . We then follow the procedure outlined in § 3 of Delisle & Ségransan (2022), where we compute the of our orbital model at each candidate frequency, where each column in matrix corresponding to orbital motion is further parameterized with the mean motion . We compute the periodogram power (Delisle & Ségransan 2022, Eq. (22)) as the fractional difference in between the null model (§ 2.4.5) and periodic model . A specified number of frequency candidates that maximize provide the initial estimates.
Radial Velocity
The periodicity in radial velocity data can also be highly non-sinusoidal, which means that a separate technique from the LS periodogram is required to provide an initial guess on the period. We use the Phase Distance Correlation (PDC) periodogram developed by Zucker (2018), which is a generalization of the Generalized Lomb-Scargle periodogram (GLS) (Zechmeister & Kürster 2009), capable of finding non-sinusoidal periodicities. The PDC serves as an appropriate framework to seed our initial period estimate, as it performs similarly to GLS in sinusoidal regimes while also handling highly eccentric orbital signals.
We start by creating a grid of trial periods whose range is set by the users prior on the period . We then calculate the PDC for each trial period using the recipe described in § 2 of Zucker (2018). The number of specified trial periods that maximize the PDC (Zucker 2018, Eq. (5)) are then selected as the initial estimates for .
Periodogram for Joint Datasets
Initialization for joint datasets requires us to find a common periodicity across an arbitrary number of datasets. To accomplish this, we use the framework developed in § 2.3, utilizing the design matrix to perform a grid search for the optimal joint period. Following the approach outlined in Delisle & Ségransan (2022), § 4.2, each column corresponding to orbital motion in is further parameterized by the mean motion . We then compute the for each trial frequency across a grid bounded by the users prior on . The described in § 3.3.2 is then calculated. The specified number of trial frequency’s that maximize the yields the inverse of the initial period estimates .
Full Seed Creation
For each initial period estimate obtained from the periodogram methods described above, a candidate parameter vector is created by filling the remaining parameters with a random sample from their priors. These are then each taken to seed SciPy’s Differential Evolution (Storn & Price 1997) algorithm, which searches the entire parameter space for a global minimum. The linearized model discussed in § 2.3 is used in the likelihood for differential evolution to prevent the optimizer from stalling in the large, full parameter space. The linear parameters are then transformed to the desired parameters for sampling.
The returned parameter vector corresponding to the highest likelihood from the differential evolution runs is then sent through a quick minimization routine with SciPy’s minimize. The final parameter vector returned from this process is then chosen as the initial guess. Finally, a small Gaussian ball is created around the initial guess to seed emcee.
Sampling
Determining the joint posterior distribution of orbital parameters poses many challenges, including strong degeneracies between parameters and highly non-linear parameter spaces. periapsis utilizes Bayesian posterior sampling to provide robust estimates on orbital parameters and their uncertainties. We offer two different samplers for Bayesian inference: affine invariant Markov Chain Monte Carlo sampling with emcee (Foreman-Mackey et al. 2013) and nested sampling via UltraNest (Buchner 2021). These two methods offer different ways of exploring the parameter space and sampling from the posterior distribution. This allows users to analyse their orbital parameters effectively and to ensure that a consistent solution exists across different sampling methods. Here, we describe the sampling methods offered and how they are implemented in periapsis.
emcee
emcee is an affine invariant Markov Chain Monte Carlo (MCMC) sampler. The sampler evolves an ensemble of starting walkers through the parameter space, where each walker’s position is updated based on the probability of the next proposed position. This allows for efficient sampling of the posterior probability density distribution, but is heavily dependent on the initial position of the walkers and can become trapped in the local minima of the distribution. This potential problem is generally resolved by our initial guessing schemes presented in § 3.3. Tracking the convergence of the walkers is important to determine the reliability of the orbital fit and the returned posterior distribution. The integrated autocorrelation time is seen as the best measure of convergence, which accounts for noise in the chain and determines the number of steps required to draw independent samples (Foreman-Mackey et al. 2013). A shorter autocorrelation time indicates better performance of the sampler. The effective sample size (ESS) is a proxy of the autocorrelation time, as it measures how many independent samples are obtained; the more independent samples, the better the convergence. The acceptance fraction, which is how often a walker step is accepted, also acts as a good indicator for MCMC performance. An acceptance fraction between 0.2 − 0.5 typically indicates good performance, although this range is dependent on the dimensionality and geometry of the parameter space (Foreman-Mackey et al. 2013; Li et al. 2024).
The user provides the amount of walkers and iterations that are desired for the sampler, where typically using a higher amount of walkers is advised (Foreman-Mackey et al. 2013). Once the sampler is initialized, there is a period of time before the walker chains become independent of each other, known as the burn-in phase. These samples should be tossed out from the final analysis for robust posterior distribution estimates. We choose to discard two times the maximum autocorrelation time for burn-in, and we thin the samples by two times the minimum autocorrelation time.
Two separate classes are offered for sampling with emcee, one for sampling the full parameter vector, MCMCFītter, and one for sampling only the non-linear parameters, MCMCLinearFitter. Both classes use the same log likelihood function presented in Equation (20), but the model positions are computed differently. MCMCFītter uses the models shown in § 2.1 and § 2.2 to sample each parameter. Fitting on the full parameter vector allows for analysis on the covariances between the parameters and robust estimation on their posterior distributions. However, the large parameter space associated with this leads to longer computational and convergence time.
MCMCLinearFitter is offered as a faster option that only samples the non-linear parameters, using the method described in § 2.3. As this method reduces the parameter space, the sampler is able to converge more efficiently.
The linear parameters are then optimized for each sampled non-linear one. In order to accurately sample the posterior of each linear parameter and account for covariance between parameters, we perform a QR factorization on the matrix WM where the matrix is factored into an orthonormal part Q and an upper triangular part R such that QR = WM (Francis [26]). We then sample by solving (by back-substitution)
where is Gaussian noise. This step is inspired by the procedure described in Bardsley et al. (2014) and accurately recovers the posterior distribution of the linear parameters found by bootstrapping or empirically calculating the covariance matrix of the marginalized linear parameters at each sampling step as in Price-Whelan et al. (2017).
A numerical bootstrapping procedure using the linear matrix is also provided in the package in case users would like to perform a bootstrap to the data by sampling with replacement and performing a linear fit on the resampled data to get another estimate of the uncertainty in each parameter.
UltraNest
In situations where the posterior distribution is multimodal, or in cases of sparse data and poor initial estimates, UltraNest (Buchner 2021) provides a robust alternative to MCMC samplers like emcee. UltraNest is a nested sampling algorithm, which takes a set of points from a unit hypercube defined by the priors (§ 3.2) and evaluates the likelihood for each of them. The lowest likelihood point is removed and replaced by a point within the newly constrained prior volume. This iteratively shrinks the investigated prior space, leaving each weighted “dead point” as a posterior sample. This process stops when the remaining live points have negligible contribution to the total estimated evidence. UltraNest uses reactive nested sampling (Buchner 2021), which allows for exploration of the entire parameter space as it begins sampling from the entire prior volume. This is a reliable method for exploring difficult parameter spaces without getting trapped in local minima, which can be a common issue for emcee.
UltraNest offers many helpful features for tuning convergence and parameter exploration. Orbital parameters that are periodic in nature (such as angles or phases spanning ) are specified as wrapped parameters inside the sampler, which prevents artificial discontinuities across periodic boundaries during nested sampling. Users can specify thresholds on the minimum number of live points sampled, the target effective sample size, and the evidence tolerance dlogz. These parameters control the accuracy of the posterior and the computational cost for likelihood evaluations. For example, a smaller dlogz requires the sampler to continue exploring the parameter space until the remaining contribution to the evidence falls below a tighter threshold. By default, dlogz = 0.5, which allows the sampler to converge quickly since we do not place a strict evidence tolerance. For poorly converged solutions, we recommend decreasing this threshold.
As with emcee, two separate classes are offered for sampling with UltraNest, UltraNestFitter and UltraNestLinearFitter. UltraNestFitter samples the full parameter vector, calculating the model positions using the framework in § 2.1 and § 2.2. Exploring the full parameter space with UltranestFitter can be computationally expensive and leads to long run times, so we generally advise to utilize nested sampling with the UltranestLinearFitter class, which reduces the parameter space down to only the non-linear parameters, using the same logic as MCMCLinearFitter (§ 3.4.1). This allows the sampler to converge very quickly while scanning the full parameter space for multi-modalities, acting as an important validation for avoiding local minima. The linear parameters are also sampled via QR decomposition, as described in § 3.4.1.
Output
periapsis offers many ways to analyse the fitted data after sampling. The results object returned after sampling is a comprehensive output featuring the full samples, the maximum a posteriori (MAP) and median parameters, initial period guesses from the periodogram (§ 3.3), and other information from the fitting procedure. Parameters that are derivable from the sampled parameters can be retrieved from the results object in any unit supported by the package. The median parameters and their uncertainties are returned in the user supplied units, while the MAP and median parameter vectors are returned in the canonical units (§ 3.1) so that they can easily be supplied to the Orbit class (§ 3.6).
Goodness of fit metrics and statistics on the performance and convergence of the sampler can be obtained from the statistics suite. The all_stats function returns all offered statistics, including reduced values for the MAP and median fits, the between the orbital fit and the null hypothesis, and other goodness of fit statistics. Convergence measuring quantities like the ESS and integrated autocorrelation time are also returned from this function.
A large number of plots are offered from the plotting suite, providing publication ready visualizations for posterior parameter distributions, convergence diagnostics, and orbital fits. This removes the need to use multiple packages to perform Bayesian inference and then visualize the fit, particularly for Gaia scanning plane astrometry.
Synthetic Binary Creation
periapsis can also be used to create synthetic binary systems for testing. This capability is provided through the Orbit class, which is also used in the likelihood for the full parameter fitter classes. By supplying a parameter vector to the Orbit class, the user can generate model positions or velocities, to which observational errors can be applied to create a synthetic binary. These synthetics are used throughout the periapsis testing suite to analyse the sampler performance and ensure that the true orbital parameters are recovered.
Experiments
To demonstrate the varied features of periapsis, in this section we apply it to varied published binary data sets. This enables us to both check its output against published values, and examine the impacts of varied sampling and fitting methods. Each example in this section is accompanied by a python notebook available on GitHub2.
oMEGACat BH-2
The code was developed in the context of fitting binaries in Cen. Our first example comes from the first binary published from that data set in Whitaker et al. (2026), oMEGACat BH-2. The fits presented in that paper were from an earlier version of the code, and thus we don’t expect identical results. The dataset includes 362 D proper motion data points from the Hubble and James Webb Space Telescope spanning 23 years after rejection of outliers in the HST data. We fit the data in two ways; using linearized parameters and sampling with UltraNest, and fitting all parameters using emcee as a sampler.
We use simple uniform priors with a maximum period of 200 years in both fits and achieve quite comparable fits to those presented in Whitaker et al. (2026), which used similar priors, but implemented a velocity dispersion based prior on the proper motions. Both the UltraNest and emcee fits find a reduced of 1.65, identical to that quoted in the original paper, with the difference between reduced on the order of 0.01. The best-fit period and eccentricity is directly comparable in both fits. Our UltraNest fit give a period of years, while the emcee fit gives years, quite comparable to the years in the paper. The eccentricity is in the UltraNest fit, in emcee and in the paper. Finally, the inferred companion mass (assuming a 0.78 M primary mass in all cases) is M in the UltraNest fit, M in the emcee fit, and M in the paper, showing quite consistent agreement despite the slight varying priors. In general, the UltraNest fits provide much smoother looking parameter distributions due to the lower dimensionality of the fits and the lack of sampling in the linearized parameters, but the period-eccentricity distributions look almost identical, showing strong covariance.
Gaia BH3
Gaia BH3 is also long-period visible star–black hole binary, with a published period of 11.6 years, and an inferred dark companion mass of 32.70±0.83 M (Gaia Collaboration et al. (2024)). The dataset available is different from oMEGACat BH-2, comprising 599 unflagged Gaia astrometric measurements and 17 Gaia radial velocity measurements both spanning 5 years. The Gaia Collaboration et al. (2024) paper presents two solutions, both with astrometry and a joint fit with astrometry and kinematics. The periapsis fit of this data is consistent with the presented values with a best-fitting mass for both solutions of M. We compare the combined fits here, but the astrometric only fit is also available in the example notebook, as is a separate notebook example where the DR4 data is downloaded and fit; each of these give somewhat different answers. The joint fit using emcee yields a reduced of 0.92, with a best-fitting period of yr, an eccentricity of , and a semi-major axis of mas; these all are consistent with errors of the best-fit joint solution published in Gaia Collaboration et al. (2024).
We also use Gaia BH3 to provide examples of plots that are produced using the periapsis’ all_plots command in Figure 2. We show the orbital fit plots here, but this command also produces parameter autocorrelation and effective sample size plots to examine convergence, corner plots and 1D histograms of all fitted parameters, residual plots, and inferred companion mass histograms.

Figure 2. Orbital solution from periapsis for Gaia BH3 fit to data from Gaia Collaboration et al. (2024), demonstrating some of the plots produced by the package. Left panels show astrometry timelines after removing the best-fit proper motion; these are combined to show the orbit on the sky in the middle panel. The right panel shows the radial velocity data. In all panels, the maximum a posteriori (MAP) fits and median fits are shown as solid red and dashed purple lines; in this case they are indistinguishable.
NGC 3201
Three candidate star–black hole binaries have been reported via untargeted MUSE spectroscopy of the low-density Galactic globular cluster NGC 3201 by Giesers et al. (2018, 2019). Here we re-fit the existing radial velocities for these three candidates.
N3201-BH1 (ID #2560) was the first of these black holes reported (Giesers et al. (2018)), with 35 published radial velocities spanning more than four years. We first fit with uniform, uninformative priors using emcee, along with the published assumed visible star mass of . We find essentially identical values of all orbital parameters to those published in Giesers et al. (2019) and the same minimum black hole mass of , though our uncertainty is a bit smaller than the published uncertainty of . Adding a prior based on the systemic velocity and velocity dispersion of the globular cluster (mean , ) does not change the inferred parameter values within their reported uncertainties, because the data already constrain the velocity of the binary to a value near the cluster mean to high precision ().
N3201-BH2 (ID #21859) is the second convincing black hole previously identified. We refit the eight radial velocities published in Giesers et al. (2019) with uniform priors using emcee, along with the published assumed visible star mass of . We find a bimodal posterior distribution, with the more prominent peak consistent with the parameters found in Giesers et al. (2019), and a secondary region of the posterior centred at a systemic velocity of about , inconsistent with the cluster. If we change the prior on to the Gaussian prior described above () and make no other changes, many of the emcee walkers still never reach the tiny phase space of the global minimum, but setting the orbital period prior to values within 10% of MAP value is sufficient to address this issue. This challenge highlights sensitivity of the fitting process to the priors when is low (see additional discussion in § 5.2). Additionally assuming the published visible star mass prior of , our final minimum black hole mass is , consistent with but more precise than the previous value of .
While Giesers et al. (2019) only publish eight velocities for this binary, three additional velocities that fell below their nominal spectroscopic signal-to-noise cut are plotted in their Figure A.1. Adding these three unpublished values and refitting changes the minimum black hole mass only very slightly to , and all other parameters likewise match the fits well within their uncertainties.
We note in passing that N3201-BH2 shows H emission, which was suggested as evidence for ongoing accretion by Giesers et al. (2019). Since the donor is far from filling its Roche lobe for the best-fit binary parameters, it is much more likely that the H emission reflects enhanced chromospheric activity due to the visible star being spun up from tidal synchronization to the black hole at its short 2.2 d period. A third binary in NGC 3201, ID #5132, is a possible black hole candidate with 22 published velocities. Giesers et al. (2019) report a bimodal posterior, with the more probable peak at ( d, ) and the less probable peak at ( d, ). The more probable peak corresponds to a minimum mass .
When we refit these data using a uniform prior fit with emcee, together with the published visible star mass of , we find that the posterior is exceptionally sensitive to the exact prior limits used, and that we can get a posterior dominated by each of these solutions with only slight variations in the assumptions. In particular, our default eccentricity prior for this fit is bounded above at for numerical stability, as the fits become unstable as approaches 1. Since the high-eccentricity solution sits near this boundary, the allowed parameter space volume is truncated and therefore not strictly uninformative. For this reason we cannot assign a relative probability to these two solutions with the existing data.
By appropriate adjustments of the prior, we can get stable posteriors that capture each of these two families of possible solutions. Additionally assuming the globular cluster prior, for the higher-mass solution, we find a minimum mass , consistent with that of Giesers et al. (2019) but with somewhat smaller uncertainties. This solution has a reduced . The lower-mass solution has a minimum mass , which would still be consistent with a compact object. Formally this solution has a lower reduced of 1.04, placing the single most outlying velocity measurement near periastron. As few as one or two additional velocity measurements made near this phase could confirm or rule out this solution and hence potentially confirm another black hole in NGC 3201.
We also explored whether an UltraNest fit would find a bimodal posterior. It did, but barely. There were very few posterior samples in the lower-mass, high eccentricity solution compared to what was found in Giesers et al. (2019), emphasizing the sensitivity of the conclusions to the prior.
Peg b
51 Peg b was the first exoplanet ever discovered orbiting a Sun-like star (Mayor & Queloz 1995), with an orbital period of 4.23 days and an inferred minimum planetary mass of (Butler et al. 2006). We fit this system using 46 high-precision radial velocity measurements from the HIRES spectrograph on the 10-m Keck-1 telescope spanning roughly 8.2 years published by Tal-Or et al. (2019), who provided a corrected version of the catalog produced by Butler et al. (2017). Butler et al. (2017) only provides published orbital parameters for , , and for 51 Peg b, so we compare both to this text and the full Keplerian parameters published in Butler et al. (2006).
We first perform an orbital fit by sampling only the non-linear parameters period , eccentricity , and the scaled time of periastron with emcee. Noninformative uniform priors are placed on and , while a log uniform prior is placed on , and the star’s mass is fixed to the published value 1.09 . We obtain nearly identical estimates of and as Butler et al. (2017), and a similar planetary mass , having smaller uncertainties but comparable to Butler et al. (2006). We obtain an
eccentricity of , slightly higher than that published in Butler et al. (2006) of . In this fit, we did not take into account any stellar activity with a radial velocity jitter term (§ 2.4.3), so the fit’s reduced is significantly inflated.
We then fit a full parameter vector, including and , with emcee. We again obtain nearly identical values to the and published by Butler et al. (2017), and , again with smaller uncertainties but comparable to Butler et al. (2006). We obtain a similar eccentricity as the last fit, but with larger uncertainties where , comparable to those published by Butler et al. (2006). The estimates for and differ from and published by Butler et al. (2017) because we fit the corrected catalog provided by Tal-Or et al. (2019). Sampling for jitter remedies the inflated reduced , yielding a reduced .
Discussion
Comparison to Existing Packages
There are several other orbital fitting codes. Many are useful in specific cases, especially for multi-body exoplanet systems, but to our knowledge, none have both the flexibility and extensibility of periapsis for fitting two-body systems. Here we briefly describe these other codes.
The Joker
The Joker (a portmanteau of Johannes Kepler) is a Python rejection sampling code that supports radial velocity data (Price-Whelan et al. 2017). The Joker excels with sparse radial velocity data where the posterior is multimodal. Rejection sampling is powerful here due to the number of samples that are tested, often exceeding (e.g. for each of the binaries tested in NGC 3201; Giesers et al. 2019). The generation of a large number of prior samples is slow (generating samples takes about a day on an Apple Silicon M1 Max with 64 GB of RAM), so The Joker may be best suited to cases where the same prior samples can be reused for a large number of binaries. In cases when an insufficient number of samples are obtained by rejection sampling, The Joker recommends using MCMC sampling to augment the existing samples and explore the nearby posterior distribution.
The Joker directly samples , , , and (which they call ). The sampler marginalizes over the linear parameters and (which they call ). The Joker supports astropy’s Quantity for input data and priors so arbitrary units are allowed.
kepmodel
kepmodel is an analytical periodogram-based orbital fitting code optimized for the Gaia pipeline (Delisle & Ségransan 2022). A candidate period is first identified from joint 1D scan-plane astrometry and radial velocities by a linear periodogram, which we replicate in our initial guess scheme as described above (§ 3.3.2). kepmodel then analytically estimates and based on the amplitudes and phases from the periodogram. With these estimates, one can solve for the linear parameters , , , , , and .
In practice, kepmodel is more flexible than described here, allowing users to add an arbitrary number of Keplerian models to a single system (e.g. for multi-planet fits) and a flexible S+LEAF noise model (Delisle et al. 2020). The user can define arbitrary linear parameters in addition to the orbital parameters described above, including parallax, acceleration terms, and instrument offsets. Although kepmodel fits data using the Thiele Innes parameterization, transformations to the following Keplerian parameters (as defined in Table A1) and their combinations are supported: , , , , , , , , , , , , , , , , , , , , , , and .
kima
kima is a C++ code with a Python interface that uses diffusive nested sampling (Faria et al. 2018; Baycroft et al. 2026). Primarily designed for exoplanet fitting, the defining feature of kima is its ability to fit planetary systems where the number of planets is not known a priori. A number of other models are also supported, including gaussian process terms and binary interaction terms. Recently kima was expanded to support Gaia astrometry (Baycroft et al. 2026).
Octofitter
Octofitter is a Julia code primarily designed for fitting orbits of directly imaged exoplanets (Thompson et al. 2023). It is named for the eight types of data it supports: relative astrometry, absolute and/or relative star and planet radial velocities, Hipparcos-Gaia proper motion anomaly, images, and interferometric data. For sampling, Octofitter uses a No U-Turn Hamiltonian Monte Carlo Sampler. The package can also sample from a wide range of orbital parameter bases.
orbitize!
orbitize! is a Python package based on the Orbits For the Impatient (OFTI; Blunt et al. 2017) algorithm, with support for MCMC and nested sampling as well (Blunt et al. 2020b, 2024). OFTI is an optimized rejection sampling algorithm that is ideal when the data covers only a small fraction of the orbital period. orbitize! allows users to perform sampling in a number of predefined parameter bases, with the standard basis defined as , , , , , (their ), , and .
orvara
Orbits from Radial Velocity, Absolute, and/or Relative Astrometry (orvara) is a Python package that supports the data types listed in its name (Brandt et al. 2021). The posterior distribution is sampled using MCMC. Sampling is done on , , , , , , , , .
Usage Recommendations: How to get a quick orbital solution
periapsis offers many ways to characterize a binary system with Bayesian inference. The variety of methods offered allows users to confidently validate their orbital fits on a variety of datasets, big and small. Here, we offer our recommendations on how to quickly obtain and validate orbital solutions for any system of interest.
In most cases, we believe it is best to first perform an orbital fit with the UltranestLinearFitter class (§ 3.4.2), which can efficiently scan the parameter space of the non-linear parameters. This is important to identify potential multimodality within the parameter space that can impact the orbital fit. For validation of the fit and a more in-depth analysis of the orbital parameters, we then recommend fitting with the MCMCFitter class (§ 3.4.1). This samples the entire orbital parameter vector, exploring the full parameter space rather than optimizing the linear ones. Using both fitting methods on the data provides a way to validate the best-fitting solution and offers different ways of analyzing the sampled parameters. The full fit method is computationally more expensive, so for large binary datasets, it is best to do a first run through with one of the linear methods, and then analyse interesting systems thoroughly with MCMCFitter.
UltranestLinearFitter can struggle to converge for sparse datasets (), potentially leading to long computational times. In this case, we recommend using the MCMCFitter or MCMCLinearFitter classes. Both methods utilize emcee, which is seeded with our periodogram based initialization methods presented in § 3.3, where a differential evolution run searches around candidate periodogram peaks before seeding emcee. The user can select the number of peaks used for initialization with the npeaks argument. In the sparse data regime, we recommend setting npeaks , which can help the sampler locate high probability solutions that sit in narrow modes of the parameter space.
Future Use Cases
The upcoming several years shows great promise for significant progress in our knowledge of binary stars. Astrometrically, the coming release of Gaia Data Release 4 and the upcoming expected high-precision astrometric data from the Roman Space Telescope (e.g. Lam et al. 2026) are both expected to find many binaries. The flexibility of periapsis to handle both these astrometric data and any additional follow up data will enable efficient orbital fitting of new sources. Ongoing and upcoming spectroscopic surveys such as 4MOST ([57]) will also enable discovery of binaries with several dedicated subsurveys devoted to finding binaries.
Acknowledgements
EK, MW, and AS acknowledge support from Hubble Space Telescope archival grant HST-AR-17033 and James Webb Space Telescope general observer grant JWST-GO-5137. JS acknowledges support from NASA grant 80NSSC26K0226. We would like to thank Kameron Goord for assistance in naming periapsis, and Gail Zasowski for helping test package. The support and resources from the Center for High Performance Computing at the University of Utah are gratefully acknowledged. During software development for periapsis, generative AI was used occasionally to provide debugging and coding assistance and as a backboard for proofreading code and text written by the authors. All prose, mathematical formulations, code, and scientific conclusions were written, derived, and independently verified by the authors.
Data Availability
The periapsis code presented in this paper is available at https://github.com/Evank2004/periapsis, and example notebooks containing the analysis in § 4 are available at https://github.com/matthewwhitaker/periapsis_examples. The observational datasets analysed in this work all come from previously published studies: 2D astrometry from the Hubble Space Telescope and the James Webb Space Telescope for oMEGACat BH-2 from Whitaker et al. (2026); astrometry and radial velocities for Gaia BH3 from Gaia Collaboration et al. (2024); MUSE radial velocities for the NGC 3201 candidates from Giesers et al. (2018, 2019); and the 51 Peg b radial velocities from Tal-Or et al. (2019) (improving on Butler et al. (2017)).
Supported Parameters and Transformations
periapsis supports a large variety of parameters for sampling, presented in Table A1. Below, we include the complete relationships between parameters not included in § 2.
Thiele-Innes and Velocity Constants
The Thiele-Innes constants are related to the Campbell elements , , and by:
To transform from the Thiele-Innes constants to the Campbell elements, we follow the procedure outlined in Popović & Pavlović (1995).
Conversions between velocity constants (, ) and semi-amplitudes () are:
Distances and Ellipse Geometry
Transformations between semi-major axis , semi-minor axis , semilatus rectum , periapsis distance , and apoapsis distance :
Angular astrometric measurements () convert to physical linear scales using distance or parallax (§ 3.1):
where distance and parallax are inversely related by (with in parsecs and in arcseconds).
Anomalies, Mean Longitudes, and Epoch Conversions
Relationships for the longitude of periastron , mean motion , scaled time of periastron , mean anomaly relative to reference epoch , mean longitude , eccentric anomaly , and the true longitude :
Transformation Graph and Algorithm
Keplerian orbits can be represented by a large number of parameterizations (see Table A1). These parameterize orbital ellipses, reference times and directions, instrument systematics, and physical observables.
While other packages restrict users to a specific parameterization, periapsis is extremely flexible: for example, a user can define priors on any combination of parameters and then sample the posterior using whatever parameterization they desire, so long as the parameters are sufficient to describe the data. The resulting posterior distribution can be transformed to any parameter defined by the combination of sampled parameters.
To accomplish this, we define a graph where each parameter in Table A1 is a node. Edges are directional and map one or more nodes to another one or more nodes. For example, one edge maps , , , to , , , via equations A1–A4. This many-to-many hypergraph can then be traversed to find the transformations necessary to transform a set of known parameters to a set of desired parameters.
The transformations are constructed as follows (for specific implementation details, see the publicly available code):
(i) Determine the initial set of known parameters and the set of desired parameters .
(ii) If , no transformation is needed.
(iii) For every parameter reachable from , find a short sequence of transformations through the graph (iteratively preferring sequences with fewer steps) from any subset of to that parameter.
(iv) Remove all except the sequences which result in the parameters in .
(v) Merge the selected sequences into a single plan, removing duplicate transformations and any transformation with results that are all already computed by an earlier step.
This greedy algorithm quickly finds a small number of transformations to reach from , although it does not guarantee the smallest possible number of transformations, which is computationally hard to find. Additionally, once the transformation plan is constructed, it is cached in memory and reused, so that subsequent calls to compute the plan come at negligible cost.
By construction from the graph, the plan is already in a topological order, such that any transformation that depends on others is completed after all those others have finished. So, running the plan only requires calling each transformation in the plan in order. These cached transformation plans allow us to efficiently transform from one basis to another in every likelihood call in order to evaluate priors and constraints on parameters that are not being directly sampled. For example, a user could put a constraint on , while directly sampling only and (§ 3.2).
This paper has been typeset from a TeX/LaTeX file prepared by the author.
References
- [26]Francis J. G. F., 1961, The Computer Journal, 4, 265
- [43]Offner S. S. R., Moe M., Kratter K. M., Sadavoy S. I., Jensen E. L. N., Tobin J. J., 2023, in Inutsuka S., Aikawa Y., Muto T., Tomida K., Tamura M., eds, Astronomical Society of the Pacific Conference Series Vol. 534, Protostars and Planets VII. ASP, p. 275 (arXiv:2203.10066), doi:10.48550/arXiv.2203.10066arxiv.org/abs/2203.10066
- [57]de Jong R. S., et al., 2019, The Messenger, 175, 3
