PoissonData

class remu.likelihood.PoissonData(data_vector)[source]

Bases: remu.likelihood.DataModel

Class for fast Poisson likelihood calculations.

The resulting object can be called like a function:

log_likelihood = likelihood_calculator(prediction)
Parameters
data_vectorarray_like int

Shape: ([a,b,...,]n_reco_bins,)

Notes

Assumes that data does not change to avoid re-calculating things:

Poisson PMF:
p(k, mu) = (mu^k / k!) * exp(-mu)
ln(p(k, mu)) = k*ln(mu) - mu - ln(k!)
ln(k!) = -ln(p(k,mu)) + k*ln(mu) - mu = -ln(p(k,1.)) - 1.

Attributes

data_vector

(ndarray) The data vector k.

k0

(ndarray) Mask where k == 0.

ln_k_factorial

(ndarray) The precomputed ln(k!).

Methods

__call__(*args, **kwargs)

Call self as a function.

generate_toy_data(reco_vector[, size])

Generate toy data according to the expectation values.

generate_toy_data_model(*args, **kwargs)

Generate toy data model according to the expectation values.

log_likelihood(reco_vector)

Calculate the likelihood of the provided expectation values.

classmethod generate_toy_data(reco_vector, size=None)[source]

Generate toy data according to the expectation values.

The reco vector can have a shape ([c,d,]n_reco_bins,). Assuming the requested size is (a,b,...,), the output will be of shape ([a,b,...,][c,d,...,]).

classmethod generate_toy_data_model(*args, **kwargs)

Generate toy data model according to the expectation values.

All arguments are passed to generate_toy_data().

log_likelihood(reco_vector)[source]

Calculate the likelihood of the provided expectation values.

The reco vector can have a shape ([c,d,]n_reco_bins,). Assuming the data is of shape ([a,b,...,]n_reco_bins,), the output will be of shape ([a,b,...,][c,d,...,]).