Entropic Quantities

qnetvo.shannon_entropy_cost_fn(ansatz, **qnode_kwargs)[source]

Constructs an ansatz-specific Shannon entropy cost function

The Shannon entropy characterizes the amount of randomness, or similarly, the amount of information is present in a random variable. Formally, let \(X\) be a discrete random variable, then the Shannon entropy is defined by the expression:

\[H(X) = -\sum_{x} P(x) \log_{2} P(x)\]

In the case of a quantum network, the Shannon entropy is defined on the measurement outcome of the network ansatz.

Parameters:
  • ansatz (NetworkAnsatz) – The ansatz circuit on which the Shannon entropy is evalutated.

  • qnode_kwargs (dictionary) – Keyword arguments passed to the execute qnodes.

Returns:

A cost function shannon_entropy(*network_settings) parameterized by the ansatz-specific network settings.

Return type:

Function

qnetvo.mutual_info_cost_fn(ansatz, priors, postmap=tensor([], dtype=float64, requires_grad=True), **qnode_kwargs)[source]

Constructs an ansatz-specific mutual information cost function.

The mutual information quantifies the information shared by two distributions \(X\) and \(Y\). This entropic quantity is expressed as

\[I(Y;X) = H(Y) + H(X) - H(XY)\]

where \(H(X) = -\sum_{i}P(X_i)\log_2(P(X_i))\) is the Shannon entropy (see qnetvo.shannon_entropy()).

The mutual information can be used to quantify the amount of communication between a sender and receiver. In a quantum prepare and measure network, we evaluate the mutual information between the collections of preparation and measurement nodes.

Parameters:
  • ansatz (NetworkAnsatz) – The ansatz circuit on which the mutual information is evaluated.

  • priors (list[np.array]) – A list of prior distributions for the inputs of each preparation node.

  • postmap (np.array) – The post-processing matrix mapping the bitstring output from the quantum device into the measurement node outputs.

  • qnode_kwargs (dictionary) – Keyword arguments passed to the execute qnodes.

Returns:

A cost function mutual_info_cost(*network_settings) parameterized by the ansatz-specific scenario settings.

Return type:

Function

Helper Functions

qnetvo.behavior_fn(network_ansatz, postmap=tensor([], dtype=float64, requires_grad=True), qnode_kwargs={})[source]

Creates an ansatz-specific function for constructing the behavior matrix.

A behavior function is created as P_Net = behavior(network_ansatz) and called as P_Net(ansatz_settings). The network behavior P_Net is a column stochastic matrix containing the conditional probabilities,

\[\mathbf{P}_{Net} = \sum_{\{x_i\}_i,y}P(y|\{x_i\}_i)|y\rangle\langle \{x_i\}_i|,\]

where \(P(y|\{x_i\}_i)\) is evaluated by a qnode for each set of inputs \(\{x_i\}_i\). The number of outputs \(y\) is \(2^N\) where \(N\) is the number of qubits.

A post-processing map \(\mathbf{L}\) may optionally be applied as \(\mathbf{L}\mathbf{P}_{Net}\) where

\[\mathbf{L} = \sum_{z,y}P(z|y)|z\rangle\langle y|.\]

In the above expression, \(z\) is a new output drawn from a new alphabet.

Parameters:
  • network_ansatz (NetworkAnsatz) – A class describing the particular quantum network.

  • postmap (optional np.ndarray) – A post-processing map applied to the bitstrings output from the quantum circuit. The postmap matrix is column stochastic, that is, each column sums to one and contains only positive values.

Returns:

A function P_Net(network_settings) that evaluates the behavior matrix for a given set of settings.

Return type:

function

qnetvo.shannon_entropy(probs)[source]

Evaluates the Shannon entropy for the given marginal probability distribution probs.

\[H(X) = -\sum_{x\in X}P(x)\log_2(P(x))\]
Parameters:

probs (np.array) – A normalized probability vector.

Returns:

The Shannon entropy.

Return type:

float