elisa.infer.likelihood#
Likelihood functions.
- pgstat_background(s: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, n: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, b_est: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, b_err: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, a: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) 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:
s (
Union[Array,ndarray,bool,number,bool,int,float,complex,TypedNdArray]) – Estimate of source counts.n (
Union[Array,ndarray,bool,number,bool,int,float,complex,TypedNdArray]) – Observed counts (source and background).b_est (
Union[Array,ndarray,bool,number,bool,int,float,complex,TypedNdArray]) – Estimate of background counts.b_err (
Union[Array,ndarray,bool,number,bool,int,float,complex,TypedNdArray]) – Uncertainty of background counts.a (
Union[Array,ndarray,bool,number,bool,int,float,complex,TypedNdArray]) – Exposure ratio between source and background observations.
- Returns:
The profile background.
References
- wstat_background(s: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, n_on: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, n_off: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, a: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Array[source]#
Optimized background for W-statistics [1] given the estimate of source.
- Parameters:
s (
Union[Array,ndarray,bool,number,bool,int,float,complex,TypedNdArray]) – Estimate of source counts.n_on (
Union[Array,ndarray,bool,number,bool,int,float,complex,TypedNdArray]) – Observed source and background counts in “on” observation.n_off (
Union[Array,ndarray,bool,number,bool,int,float,complex,TypedNdArray]) – Observed background counts in “off” observation.a (
Union[Array,ndarray,bool,number,bool,int,float,complex,TypedNdArray]) – Exposure ratio between “on” and “off” observations.
- Returns:
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 | TypedNdArray = 0.0, scale: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray = 1.0, *, validate_args: bool | None = None) None[source]#
Bases:
NormalAttributes
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)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
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__().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
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_cdf
rsample
set_default_validate_args
support
tree_flatten
tree_unflatten
- class BetterPoisson(rate: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, *, is_sparse: bool = False, validate_args: bool | None = None)[source]#
Bases:
PoissonAttributes
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)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
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__().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
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
rsample
set_default_validate_args
support
tree_flatten
tree_unflatten
- 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.