JokerPrior

class thejoker.JokerPrior(pars=None, poly_trend=1, v0_offsets=None, model=None)[source]

Bases: object

This class controls the prior probability distributions for the parameters used in The Joker.

This initializer is meant to be flexible, allowing you to specify the prior distributions on the linear and nonlinear parameters used in The Joker. However, for many use cases, you may want to just use the default prior: To initialize this object using the default prior, see the alternate initializer JokerPrior.default().

Parameters
parsdict, list (optional)

Either a list of pymc3 variables, or a dictionary of variables with keys set to the variable names. If any of these variables are defined as deterministic transforms from other variables, see the next parameter below.

poly_trendint (optional)

Specifies the number of coefficients in an additional polynomial velocity trend, meant to capture long-term trends in the data. The default here is polytrend=1, meaning one term: the (constant) systemtic velocity. For example, poly_trend=3 will sample over parameters of a long-term quadratic velocity trend.

v0_offsetslist (optional)

A list of additional Gaussian parameters that set systematic offsets of subsets of the data. TODO: link to tutorial here

modelpymc3.Model

This is either required, or this function must be called within a pymc3 model context.

Attributes Summary

n_offsets

par_names

par_units

Methods Summary

default([P_min, P_max, sigma_K0, P0, …])

An alternative initializer to set up the default prior for The Joker.

sample(self[, size, generate_linear, …])

Generate random samples from the prior.

Attributes Documentation

n_offsets
par_names
par_units

Methods Documentation

classmethod default(P_min=None, P_max=None, sigma_K0=None, P0=<Quantity 1. yr>, sigma_v=None, s=None, poly_trend=1, v0_offsets=None, model=None, pars=None)[source]

An alternative initializer to set up the default prior for The Joker.

The default prior is:

\[\begin{split}p(P) \propto \frac{1}{P} \quad ; \quad P \in (P_{\rm min}, P_{\rm max})\\ p(e) = B(a_e, b_e)\\ p(\omega) = \mathcal{U}(0, 2\pi)\\ p(M_0) = \mathcal{U}(0, 2\pi)\\ p(s) = 0\\ p(K) = \mathcal{N}(K \,|\, \mu_K, \sigma_K)\\ \sigma_K = \sigma_{K, 0} \, \left(\frac{P}{P_0}\right)^{-1/3} \, \left(1 - e^2\right)^{-1/2}\end{split}\]

and the priors on any polynomial trend parameters are assumed to be independent, univariate Normals.

This prior has sensible choices for typical binary star or exoplanet use cases, but if you need more control over the prior distributions you might need to use the standard initializer (i.e. JokerPrior(...)`) and specify all parameter distributions manually. See the documentation for tutorials that demonstrate this functionality.

Parameters
P_minQuantity [time]

Minimum period for the default period prior.

P_maxQuantity [time]

Maximum period for the default period prior.

sigma_K0Quantity [speed]

The scale factor, \(\sigma_{K, 0}\) in the equation above that sets the scale of the semi-amplitude prior at the reference period, P0.

P0Quantity [time]

The reference period, \(P_0\), used in the prior on velocity semi-amplitude (see equation above).

sigma_vQuantity (or iterable of)

The standard deviations of the velocity trend priors.

sQuantity [speed]

The jitter value, assuming it is constant.

poly_trendint (optional)

Specifies the number of coefficients in an additional polynomial velocity trend, meant to capture long-term trends in the data. The default here is polytrend=1, meaning one term: the (constant) systemtic velocity. For example, poly_trend=3 will sample over parameters of a long-term quadratic velocity trend.

v0_offsetslist (optional)

A list of additional Gaussian parameters that set systematic offsets of subsets of the data. TODO: link to tutorial here

modelpymc3.Model (optional)

If not specified, this will create a model instance and store it on the prior object.

parsdict, list (optional)

Either a list of pymc3 variables, or a dictionary of variables with keys set to the variable names. If any of these variables are defined as deterministic transforms from other variables, see the next parameter below.

sample(self, size=1, generate_linear=False, return_logprobs=False, random_state=None, dtype=None, **kwargs)[source]

Generate random samples from the prior.

Note

Right now, generating samples with the prior values is slow (i.e. with return_logprobs=True) because of pymc3 issues (see discussion here: https://discourse.pymc.io/t/draw-values-speed-scaling-with-transformed-variables/4076). This will hopefully be resolved in the future…

Parameters
sizeint (optional)

The number of samples to generate.

generate_linearbool (optional)

Also generate samples in the linear parameters.

return_logprobsbool (optional)

Generate the log-prior probability at the position of each sample.

**kwargs

Additional keyword arguments are passed to the JokerSamples initializer.

Returns
samplesthejoker.Jokersamples

The random samples.