mlae_utils

This module contains mandatory functions used by the MLAE class

Author: Gonzalo Ferro Costas & Alberto Manzano Herrero

QQuantLib.AE.mlae_utils.cost_function(angle: float, m_k: list, n_k: list, h_k: list) float

This method calculates the -Likelihood of angle theta for a given schedule m_k,n_k

Notes

\[L(\theta,\mathbf{h}) = -\sum_{k = 0}^M\log{l_k(\theta|h_k)}\]
Parameters:
  • angle (float) – Angle (radians) for calculating the probability of measure a positive event.

  • m_k (list of ints) – number of times the grover operator was applied.

  • n_k (list of ints) – number of total events measured for the specific m_k

  • h_k (list of ints) – number of positive events measured for each m_k

Returns:

cost – the aggregation of the individual likelihoods

Return type:

float

QQuantLib.AE.mlae_utils.likelihood(theta: float, m_k: int, n_k: int, h_k: int) float

Calculates Likelihood from Suzuki paper. For h_k positive events of n_k total events, this function calculates the probability of this taking into account that the probability of a positive event is given by theta and by m_k The idea is use this function to minimize it for this reason it gives minus Likelihood

Notes

\[l_k(\theta|h_k) = \sin^2\left((2m_k+1)\theta\right)^{h_k} \ \cos^2 \left((2m_k+1)\theta\right)^{n_k-h_k}\]
Parameters:
  • theta (float) – Angle (radians) for calculating the probability of measure a positive event.

  • m_k (int) – number of times the grover operator was applied.

  • n_k (int) – number of total events measured for the specific m_k

  • h_k (int) – number of positive events measured for each m_k

Returns:

Gives the Likelihood p(h_k with m_k amplifications|theta)

Return type:

float

QQuantLib.AE.mlae_utils.log_likelihood(theta: float, m_k: int, n_k: int, h_k: int) float

Calculates log of the likelihood from Suzuki paper.

Notes

\[\log{l_k(\theta|h_k)} = 2h_k\log\big[\sin\left((2m_k+1) \ \theta\right)\big] +2(n_k-h_k)\log\big[\cos\left((2m_k+1) \ \theta\right)\big]\]
Parameters:
  • theta (float) – Angle (radians) for calculating the probability of measure a positive event.

  • m_k (int) – number of times the grover operator was applied.

  • n_k (int) – number of total events measured for the specific m_k

  • h_k (int) – number of positive events measured for each m_k

Returns:

Gives the log Likelihood p(h_k with m_k amplifications|theta)

Return type:

float