Events#

class scikitplot._astropy.stats.Events(p0=0.05, gamma=None, ncp_prior=None)[source]#

Bayesian blocks fitness for binned or unbinned events.

Parameters:
p0float, optional

False alarm probability, used to compute the prior on \(N_{\rm blocks}\) (see eq. 21 of Scargle 2013). For the Events type data, p0 does not seem to be an accurate representation of the actual false alarm probability. If you are using this fitness function for a triggering type condition, it is recommended that you run statistical trials on signal-free noise to determine an appropriate value of gamma or ncp_prior to use for a desired false alarm rate.

gammafloat, optional

If specified, then use this gamma to compute the general prior form, \(p \sim {\tt gamma}^{N_{\rm blocks}}\). If gamma is specified, p0 is ignored.

ncp_priorfloat, optional

If specified, use the value of ncp_prior to compute the prior as above, using the definition \({\tt ncp\_prior} = -\ln({\tt gamma})\). If ncp_prior is specified, gamma and p0 is ignored.

Parameters:
compute_ncp_prior(N)[source]#

If ncp_prior is not explicitly defined, compute it from gamma or p0.

Parameters:

N (int)

Return type:

float

fit(t, x=None, sigma=None)[source]#

Fit the Bayesian Blocks model given the specified fitness function.

Parameters:
tarray-like

data times (one dimensional, length N)

xarray-like, optional

data values

sigmaarray-like or float, optional

data errors

Returns:
edgesndarray

array containing the (M+1) edges defining the M optimal bins

Parameters:
  • t (ArrayLike)

  • x (ArrayLike | None)

  • sigma (ArrayLike | float | None)

Return type:

NDArray[float]

fitness(N_k, T_k)[source]#
Parameters:
Return type:

NDArray[float]

p0_prior(N)[source]#

Empirical prior, parametrized by the false alarm probability p0.

See eq. 21 in Scargle (2013).

Note that there was an error in this equation in the original Scargle paper (the “log” was missing). The following corrected form is taken from https://arxiv.org/abs/1304.2818

Parameters:

N (int)

Return type:

float

validate_input(t, x, sigma)[source]#

Validate inputs to the model.

Parameters:
tarray-like

times of observations

xarray-like, optional

values observed at each time

sigmafloat or array-like, optional

errors in values x

Returns:
t, x, sigmaarray-like, float

validated and perhaps modified versions of inputs

Parameters:
  • t (ArrayLike)

  • x (ArrayLike | None)

  • sigma (float | ArrayLike | None)

Return type:

tuple[NDArray[float], NDArray[float], NDArray[float]]