Probability Functions for Exact Poisson Binomial

These functions are used by the ExactPoissonContribution() call of the LogLikelihood class to calculate a precise version of the Poisson Binomial probability. This version is very slow, so unless significant deviations are expeected, the inexact versions should be used.

Forward Loop

void poisson_binomial_lpmf_forward(std::vector<double> &probs, int probslen, std::vector<std::vector<double>> &result)

Called by LogLikelihood::ExactPoissonContribution(). Almost identical to poisson_binomial_pmf_forward(), but operates in log-space and has a far higher level of precision, and crucially is much slower. This should only be called when the results of the original function are in doubt (p ~1 or p~0, or result[x][y] > infty)

Parameters
  • probs – The vector of probabilities to calculate the Poisson Binomial on. This vector has length NumberLargerThanMaxObservations, to prevent continual re-initialisation

  • probslen – The number of elements of probs which are initialised. Referred to as n in our theory work

  • result – A reference to a matrix / vector-of-vectors used to store the output result in-place. The value of p(K = k| probs) is at element [n-1][k]. The rest of the object is populated with intermediary results needed to calculate the derivative of the result w.r.t. the probabilities.

Backward Loop

void poisson_binomial_lpmf_backward(std::vector<double> &probs, int probslen, std::vector<std::vector<double>> &result)

Called by LogLikelihood::ExactPoissonContribution(). Acts almost identically to poisson_binomial_lpmf_forward(), but the convolution happens in reverse order, therefore populating result with a different set of intermediary results. Again, note that this is considerably slower than poisson_binomial_pmf_backward().

Parameters
  • probs – The vector of probabilities to calculate the Poisson Binomial on. This vector has length NumberLargerThanMaxObservations, to prevent continual re-initialisation

  • probslen – The number of elements of probs which are initialised. Referred to as n in our theory work

  • result – A reference to a matrix / vector-of-vectors used to store the output result in-place. The value of p(K = k| probs) is at element [k][n-1]. The rest of the object is populated with intermediary results needed to calculate the derivative of the result w.r.t. the probabilities.

Sub-pmf Loop

void poisson_binomial_sublpmf(int m, int probslen, std::vector<std::vector<double>> &lpmf_forward, std::vector<std::vector<double>> &lpmf_backward, std::vector<double> &result)

Uses the output of poisson_binomial_lpmf_forward() and poisson_binomial_lpmf_forward() to calculate the correct (exact) contribution to the derivative of the probabiity (needed for the gradient descent).

Parameters
  • m – An offset parameter either #PipelineMinVisists -1 , k-1 or k, depending on the properties of the star which have been observed.

  • pmf_forward – the output of poisson_binomial_pmf_forward()

  • pmf_backward – the output of poisson_binomial_pmf_backward()

  • result – The vector into which the results are inserted in-place