reggae.utils ============ .. py:module:: reggae.utils Classes ------- .. autoapisummary:: reggae.utils.jaxInterp1D reggae.utils.scalingRelations reggae.utils.normal reggae.utils.uniform reggae.utils.beta Functions --------- .. autoapisummary:: reggae.utils.readBkgFits reggae.utils.to_log10 reggae.utils._update_x reggae.utils._func_1 reggae.utils._func_2 reggae.utils._compute_x reggae.utils._betaincinv Module Contents --------------- .. py:function:: readBkgFits(ID) Read background samples during prior. Read in the previosly fit background model parameters to use as a prior during sampling. Paramaters ---------- ID : str Target identifier Returns ------- out : dict Dictionary containing parameters for three harvey laws. .. py:class:: jaxInterp1D(xp, fp, left=None, right=None, period=None) Replacement for scipy.interpolate.interp1d in jax This is used to initialize a callable object for interpolating. .. py:attribute:: xp .. py:attribute:: fp .. py:attribute:: left :value: None .. py:attribute:: right :value: None .. py:attribute:: period :value: None .. py:method:: __call__(x) Evalute the interpolant on given values Parameters ---------- x : jnp.array jax array of points to evaluate the interpolant at. Returns ------- interp : jnp.array The interpolated values. .. py:class:: scalingRelations Container for scaling relations This is a helper class which contains methods for the various scaling relations. .. py:method:: __init_() .. py:method:: dnuScale(nu, gamma=0.0, p=[0.79101684, -0.63285292]) Compute dnu from numax Computes an estimate of the large separation from a given value of numax, assuming the two parameters scale as a polynomial in log(dnu) and log(numax). The default is a linear function in log(dnu) and log(numax), estimated based on a polynomial fit performed on a set of main-sequence and sub- giant stars in the literature. The output may be scaled by a factor gamma, e.g., for setting credible intervals. Parameters ---------- nu : float, array Value(s) at which to compute dnu, assuming nu corresponds to numax. (muHz) gamma : float Scaling factor to apply. p : array-like, optional Polynomial coefficients to use for log(dnu), log(numax), starting with the coefficient of the Nth order term and ending at the bias term. Returns ------- dnu : float, array Estimate of the large separation dnu .. py:method:: envWidth(numax) Scaling relation for the envelope width Computes the the estimated full width at half maximum of the p-mode envelope based on numax. Parameters ---------- numax : float Frequency of maximum power of the p-mode envelope. Returns ------- width : float Envelope width in muHz .. py:function:: to_log10(x, xerr) Transform to value to log10 Takes a value and related uncertainty and converts them to logscale. Approximate. Parameters ---------- x : float Value to transform to logscale xerr : float Value uncertainty Returns ------- logval : list logscaled value and uncertainty .. py:class:: normal(**kwargs) .. py:attribute:: norm .. py:attribute:: lognorm .. py:attribute:: fac .. py:method:: pdf(x, norm=True) Evaluate the probability density function Returns the probability density of the normal distribution at x. The distribution is normalized to unit integral by default so that it may be used as a PDF. In some cases the normalization is not necessary, and since it's marginally slower it may as well be left out. Parameters ---------- x : array Support for the probability density. Returns ------- y : array The probability density at x. .. py:method:: logpdf(x, norm=True) Evaluate the log-probability density function Returns the probability density of the normal distribution at x. The distribution is normalized to unit integral by default so that it may be used as a PDF. In some cases the normalization is not necessary, and since it's marginally slower it may as well be left out. Parameters ---------- x : array Support for the probability density. Returns ------- y : array The probability density at x. .. py:method:: cdf(x) Evaluate the cummulative distribution function Returns cummulative probability density of the normal distribution at x. Parameters ---------- x : array Support for the probability density. Returns ------- y : array The probability density at x. .. py:method:: ppf(y) Evaluate the quantile function Returns support corresponding to a given quantile between 0 and 1 for the normal distribution. Parameters ---------- y : array Quantile value. Returns ------- x : array The support for the PDF corresponding to quantile value y. .. py:class:: uniform(**kwargs) .. py:attribute:: a .. py:attribute:: b .. py:attribute:: mu .. py:method:: pdf(x) Evaluate the probability density function Returns the probability density of the uniform distribution at x. The distribution is normalized to unit integral by default so that it may be used as a PDF. Parameters ---------- x : array Support for the probability density. Returns ------- y : array The probability density at x. .. py:method:: logpdf(x) Evaluate the log-probability density function Returns the probability density of the uniform distribution at x. The distribution is normalized to unit integral by default so that it may be used as a PDF. In some cases the normalization is not necessary, and since it's marginally slower it may as well be left out. Parameters ---------- x : array Support for the probability density. Returns ------- y : array The probability density at x. .. py:method:: cdf(x) Evaluate the cummulative distribution function Returns cummulative probability density of the uniform distribution at x. Parameters ---------- x : array Support for the probability density. Returns ------- y : array The probability density at x. .. py:method:: ppf(y) Evaluate the quantile function Returns support corresponding to a given quantile between 0 and 1 for the uniform distribution. Parameters ---------- y : array Quantile value. Returns ------- x : array The support for the PDF corresponding to quantile value y. .. py:class:: beta(**kwargs) .. py:attribute:: loc :value: 0 .. py:attribute:: scale :value: 1 .. py:attribute:: fac .. py:attribute:: logfac .. py:attribute:: am1 .. py:attribute:: bm1 .. py:method:: _transformx(x) Transform x Translates and scales the input x to the unit interval according to the loc and scale parameters. Parameters ---------- x : array-like Input support for the probability density. Returns ------- _x : array-like x translated and scaled to the range 0 to 1. .. py:method:: _inverse_transform(x) Invert transformation on x Translates and scales the input x to the original interval according to the loc and scale parametrs. Parameters ---------- x : array-like Input support for the probability on the interval 0 to 1. Returns ------- _x : array-like x translated and scaled from the range 0 to 1 to the loc and scale. .. py:method:: pdf(x, norm=True) Return PDF Returns the beta distribution at x. The distribution is normalized to unit integral by default so that it may be used as a PDF. In some cases the normalization is not necessary, and since it's marginally slower it may as well be left out. Parameters ---------- x : array Input support for the probability density. norm : bool, optional If true, returns the normalized beta distribution. The default is True. Returns ------- y : array The value of the beta distribution at x. .. py:method:: logpdf(x, norm=True) Return log-PDF Returns the log of the beta distribution at x. The distribution is normalized to unit integral (in linear units) by default so that it may be used as a PDF. In some cases the normalization is not necessary, and since it's marginally slower it may as well be left out. Parameters ---------- x : array Input support for the probability density. norm : bool, optional If true, returns the normalized beta distribution. The default is True. Returns ------- y : array The value of the logarithm of the beta distribution at x. .. py:method:: cdf(x) Evaluate the cummulative distribution function Returns cummulative probability density of the uniform distribution at x. Parameters ---------- x : array Support for the probability density. Returns ------- y : array The probability density at x. .. py:method:: ppf(y) Evaluate the quantile function Returns support corresponding to a given quantile between 0 and 1 for the beta distribution. Parameters ---------- y : array Quantile value. Returns ------- x : array The support for the PDF corresponding to quantile value y. .. py:function:: _update_x(x, a, b, p, a1, b1, afac) Helper function for evaluating the beta distribution quantile function .. py:function:: _func_1(a, b, p) Helper function for evaluating the beta distribution quantile function .. py:function:: _func_2(a, b, p) Helper function for evaluating the beta distribution quantile function .. py:function:: _compute_x(p, a, b) Helper function for evaluating the beta distribution quantile function .. py:function:: _betaincinv(a, b, p) Helper function for evaluating the beta distribution quantile function