Probability Functions for Poisson Binomial

These functions are used by the PoissonContribution() call of the LogLikelihood class to calculate a slightly truncated / rounded version of the Poisson Binomial probability. If these functions misbehave (as they are liable to do when a member of {p_i} is close to 0 or 1), then the exact versions should be used.

Forward Loop

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

Called by LogLikelihood::PoissonContribution(). Uses a truncated convolution to calculate p(K =k | probs). The implementation is heavily based on the one we stole from github

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_pmf_backward(std::vector<double> &probs, int probslen, std::vector<std::vector<double>> &result)

Called by LogLikelihood::PoissonContribution(). Acts almost identically to poisson_binomial_pmf_forward(), but the convolution happens in reverse order, therefore populating result with a different set of intermediary results.

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_subpmf(int m, int probslen, std::vector<std::vector<double>> &pmf_forward, std::vector<std::vector<double>> &pmf_backward, std::vector<double> &result)

Uses the output of poisson_binomial_pmf_forward() and poisson_binomial_pmf_forward() to calculate the correct 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