Evaluation

evaluate_monomial(n, n_measure, circuit, a_a_p_coeffs, shots, is_simulation=True, monitor=False, local=True)[source]
Draws the circuit if there are some additions and runs it to get the
measurement of a monomial
Parameters:
  • n (int) – The number of qubits.
  • n_measure (int) – The measurement to be performed. Dictates whether a_i or a’_i is used on each wire.
  • circuit (QuantumCircuit) – The original quantum circuit.
  • a_a_p_coeffs (array[float]) – The coefficients of the matrices used to calculate Mermin operators.
  • shots (int) – The number of repetitions of each circuit. Default: 1024.
  • is_simulation (boolean) – This determines if we are in a case of a local test or a real IBM machine test.
  • monitor (boolean) – If true a monitor is attached to the job.
  • local (boolean) – If true, the job run on a local simulator.
Returns:

float – The result of the measurement probabilities on one monomial.

evaluate_polynomial(n, circuit, a_a_p_coeffs, shots=1024, is_simulation=True, monitor=False, local=True)[source]

Makes all the implementation and calculation

Caution!:
The IBMQ account must be loaded before the execution of this function if the variable is_simulation is set to False.
Parameters:
  • n (int) – The number of qubits.
  • circuit (QuantumCircuit) – The original quantum circuit.
  • a_a_p_coeffs (list[list[any]]) – Lists of lists of elements as described above (packed coefficients).
  • shots (int) – The number of times that the measurements are made. This is only in case of a local test.
  • is_simulation (boolean) – To specify if the codes are to run locally or on the IBM machine.
  • monitor (boolean) – If true a monitor is attached to the job.
  • local (boolean) – If true, the job run on a local simulator.
Returns:

float – The result of all the calculations.

measures_exploitation(measures_dictionary, shots)[source]

Calculates the measurements probabilities

For every possible cases (for example, with n = 2 : 00 01 10 11), the probability to get this combination when measuring is calculated.

In order to obtain this probabilities, we sum the values of the cases where the number of 1 in the measurement is even and when it’s then odd.

Example :
even_results = values of 00 and 11 measurements odd_results = values of 01 and 10 measurements
Parameters:
  • measures_dictionary (dict) – the dictionary containing the measurements and their values.
  • shots (int) – the number of times that the measurements are made. This is only in case of a local test.
Returns:

float – The total probability of the dictionary measurement.

mermin_IBM(n)[source]
Returns the Mermin polynomials under a vector form. This form helps to
form the corrects monomials that involves in every mermin evaluation.
Example :
In this case, the involving monomials are only the second one, the third one, the fith one and the last one because the others are equal to zero. >>> mermin_IBM(3) [0.0, 0.5, 0.5, 0.0, 0.5, 0.0, 0.0, -0.5]
Parameters:n (int) – The number of qubits.
Returns:list(float) – The list of numbers corresponding to the existence and the value each monomial.