chronpy.psd#
- class Lightcurve(t: NDArray, counts: NDArray, tbins: NDArray = None, exposure: NDArray = None)[source]#
Bases:
objectAttributes
counts
dt
evenly_sampled
exposure
rate
t
tbins
- class PSD(freq_bins: ndarray, power: ndarray, dof: ndarray, dt: float, df: float)[source]#
Bases:
objectAttributes
bins_width
density
derr
df
dof
dt
freq
freq_bins
perr
power
Methods
from_lc
- abstract classmethod from_lc(lc: Lightcurve | list[Lightcurve], norm: str = 'leahy')[source]#
- class Periodogram(freq_bins: ndarray, power: ndarray, dof: ndarray, dt: float, df: float)[source]#
Bases:
PSDAttributes
bins_width
density
derr
df
dof
dt
freq
freq_bins
perr
power
Methods
from_lc
rebin_log
rebin_significance
- classmethod from_lc(lc: Lightcurve | list[Lightcurve], norm: str = 'leahy')[source]#
- class PowerDist(dof, s)[source]#
Bases:
GammaThe probability density function of the power spectrum.
We know that if X ~ Chi_v^2, then cX ~ Gamma(alpha=v/2, scale=c/2).
For the power spectrum, we know that vI/S ~ Chi_v^2, where I is the observed power, v is the dof of I, and S is the true power. Then the underlying distribution of I is Gamma(alpha=v/2, scale=2S/v).
If I is obtained by summing over the power of m adjacent frequency bins, I = sum_{m} I_m, then there is no analytical expression for the distribution of I, since the Gamma dist’s scale of each I_m is different. If we assume that the expected powers of I_m are the same, then the distribution of I is Gamma(alpha=sum_{m} v_m/2, scale=2S/(sum_{m} v_m)). However, this is usually not the case for the observed powers of I_m, and this assumption may underestimate the variance of I, thus leading to a deviance that is systematically larger than the fit dof, i.e., number of data points minus number of parameters.
Averaging the powers of l different power spectrum is valid, and the distribution of the average power I_j is Gamma(alpha=l*v_j/2, scale=2S/(l*v_j)).
Attributes
batch_shapeReturns the shape over which the distribution parameters are batched.
event_dimevent_shapeReturns the shape of a single sample from the distribution without batching.
meanMean of the distribution.
varianceVariance of the distribution.
has_rsample
is_discrete
Methods
__call__(*args, **kwargs)Call self as a function.
cdf(x)The cumulative distribution function of this distribution.
entropy()Returns the entropy of the distribution.
enumerate_support([expand])Returns an array with shape len(support) x batch_shape containing all values in the support.
expand(batch_shape)Returns a new
ExpandedDistributioninstance with batch dimensions expanded to batch_shape.expand_by(sample_shape)Expands a distribution by adding
sample_shapeto the left side of itsbatch_shape.get_args()Get arguments of the distribution.
icdf(q)The inverse cumulative distribution function of this distribution.
infer_shapes(*args, **kwargs)Infers
batch_shapeandevent_shapegiven shapes of args to__init__().mask(mask)Masks a distribution by a boolean or boolean-valued array that is broadcastable to the distributions
Distribution.batch_shape.sample(key[, sample_shape])Returns a sample from the distribution having shape given by sample_shape + batch_shape + event_shape.
sample_with_intermediates(key[, sample_shape])Same as
sampleexcept that any intermediate computations are returned (useful for TransformedDistribution).shape([sample_shape])The tensor shape of samples from this distribution.
to_event([reinterpreted_batch_ndims])Interpret the rightmost reinterpreted_batch_ndims batch dimensions as dependent event dimensions.
validate_args([strict])Validate the arguments of the distribution.
gather_pytree_aux_fields
gather_pytree_data_fields
log_prob
rsample
set_default_validate_args
support
tree_flatten
tree_unflatten
- log_prob(*args, **kwargs)#
Evaluates the log probability density for a batch of samples given by value.
- Parameters:
value – A batch of samples from the distribution.
- Returns:
an array with shape value.shape[:-self.event_shape]
- Return type:
- class Fit(psd: PSD, model: Model)[source]#
Bases:
objectAttributes
loss
ndata
nparam
numpyro_model
params_names
transform
Methods
batch_fit
mle
mle_lm
run_nuts
simulate
- property ndata#
- property nparam#
- property numpyro_model#
- run_nuts(num_warmup=2000, num_samples=2000, num_chains=4, init=None, chain_method='parallel', progress=True, seed=42)[source]#
- property loss#
- property params_names#
- property transform#