elisa.infer.likelihood#

Likelihood functions.

pgstat_background(s: Array | ndarray | bool | number | bool | int | float | complex, n: Array | ndarray | bool | number | bool | int | float | complex, b_est: Array | ndarray | bool | number | bool | int | float | complex, b_err: Array | ndarray | bool | number | bool | int | float | complex, a: Array | ndarray | bool | number | bool | int | float | complex) Array[source]#

Optimized background for PG-statistics given estimate of source counts.

Note

The optimized background here is always non-negative, which differs from XSPEC [1].

Parameters:
sarray_like

Estimate of source counts.

narray_like

Observed counts (source and background).

b_estarray_like

Estimate of background counts.

b_errarray_like

Uncertainty of background counts.

afloat or array_like

Exposure ratio between source and background observations.

Returns:
JAXArray

The profile background.

References

wstat_background(s: Array | ndarray | bool | number | bool | int | float | complex, n_on: Array | ndarray | bool | number | bool | int | float | complex, n_off: Array | ndarray | bool | number | bool | int | float | complex, a: Array | ndarray | bool | number | bool | int | float | complex) Array[source]#

Optimized background for W-statistics [1] given the estimate of source.

Parameters:
sarray_like

Estimate of source counts.

n_onarray_like

Observed source and background counts in “on” observation.

n_offarray_like

Observed background counts in “off” observation.

aarray_like

Exposure ratio between “on” and “off” observations.

Returns:
JAXArray

The profile background.

References

[1]

Wachter, K., Leach, R., & Kellogg, E. (1979). Parameter estimation in X-ray astronomy using maximum likelihood. ApJ, 230, 274–287.

class BetterNormal(loc: Array | ndarray | bool | number | bool | int | float | complex = 0.0, scale: Array | ndarray | bool | number | bool | int | float | complex = 1.0, *, validate_args: bool | None = None) None[source]#

Bases: Normal

Attributes

batch_shape

Returns the shape over which the distribution parameters are batched.

event_dim

event_shape

Returns the shape of a single sample from the distribution without batching.

mean

Mean of the distribution.

variance

Variance of the distribution.

has_rsample

is_discrete

Methods

__call__(*args, **kwargs)

Call self as a function.

cdf(value)

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 ExpandedDistribution instance with batch dimensions expanded to batch_shape.

expand_by(sample_shape)

Expands a distribution by adding sample_shape to the left side of its batch_shape.

get_args()

Get arguments of the distribution.

icdf(q)

The inverse cumulative distribution function of this distribution.

infer_shapes(*args, **kwargs)

Infers batch_shape and event_shape given shapes of args to __init__().

log_prob(value)

Evaluates the log probability density for a batch of samples given by value.

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 sample except 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_cdf

rsample

set_default_validate_args

support

tree_flatten

tree_unflatten

log_prob(value)[source]#

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:

ArrayLike

class BetterPoisson(rate: Array | ndarray | bool | number | bool | int | float | complex, *, is_sparse: bool = False, validate_args: bool | None = None)[source]#

Bases: Poisson

Attributes

batch_shape

Returns the shape over which the distribution parameters are batched.

event_dim

event_shape

Returns the shape of a single sample from the distribution without batching.

mean

Mean of the distribution.

variance

Variance of the distribution.

has_rsample

is_discrete

Methods

__call__(*args, **kwargs)

Call self as a function.

cdf(value)

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 ExpandedDistribution instance with batch dimensions expanded to batch_shape.

expand_by(sample_shape)

Expands a distribution by adding sample_shape to the left side of its batch_shape.

get_args()

Get arguments of the distribution.

icdf(q)

The inverse cumulative distribution function of this distribution.

infer_shapes(*args, **kwargs)

Infers batch_shape and event_shape given shapes of args to __init__().

log_prob(value)

Evaluates the log probability density for a batch of samples given by value.

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 sample except 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

rsample

set_default_validate_args

support

tree_flatten

tree_unflatten

log_prob(value)[source]#

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:

ArrayLike

chi2(data: FixedData, model: Callable[[Array, dict[str, Array]], Array]) Callable[[dict[str, Array], bool], None][source]#

S^2 statistic, Gaussian likelihood.

cstat(data: FixedData, model: Callable[[Array, dict[str, Array]], Array]) Callable[[dict[str, Array], bool], None][source]#

C-statistic, Poisson likelihood.

pstat(data: FixedData, model: Callable[[Array, dict[str, Array]], Array]) Callable[[dict[str, Array], bool], None][source]#

P-statistic, Poisson likelihood for data with a known background.

pgstat(data: FixedData, model: Callable[[Array, dict[str, Array]], Array]) Callable[[dict[str, Array], bool], None][source]#

PG-statistic, Poisson likelihood for data and profile Gaussian likelihood for background.

wstat(data: FixedData, model: Callable[[Array, dict[str, Array]], Array]) Callable[[dict[str, Array], bool], None][source]#

W-statistic, i.e. Poisson likelihood for data and profile Poisson likelihood for background.