# What is the variance associated to the average gate fidelity?

Let $U$ be a unitary and $\mathcal E$ a map on a space of dimension $D$, and say we want to assess how "close" $U$ is to $\mathcal E$.

A standard way to do this is using the average fidelity $\overline{F}(\mathcal E, U)$, defined as $$\overline{F}(\mathcal E, U)\equiv\int d\psi \langle\psi\rvert U^\dagger \mathcal E(|\psi\rangle\langle\psi|) U|\psi\rangle.\tag1$$ It is a standard result (see e.g. quant-ph/0205035) that (1) can be computed as $$\overline{F}(\mathcal E, U) = \frac{1}{D+1}\left[ 1 + \frac{1}{D} \langle i|U^\dagger \mathcal E(|i\rangle\langle j|)U|j\rangle \right]. \tag2$$

In the special case of $\mathcal E$ also being a unitary evolution (that is, $\mathcal E(\rho)=V\rho V^\dagger$ for some unitary $V$), the formula simplifies to $$\overline{F}(V, U) = \frac{1}{D+1}\left[ 1 + \frac{1}{D} \lvert\operatorname{tr}(U^\dagger V)\rvert^2 \right]. \tag2$$ These expressions are very useful as they allow to compute the average fidelity without actually computing an average over the states.

I wasn't however able to find discussed the matter of what the variance of this quantity actually is. In other words, if I were to try to estimate (1) using a sample size of $N$ states, how likely am I to get a value close enough to the true average given by (2)?

To more clearly understand the question, here is a plot of the average fidelity between two unitary gates, estimated with various sample sizes and compared with the true value given by (3) (python code used to generated it available in this gist):

I want to know how big do I need to choose the sample size in order to have a good enough estimate with a good enough confidence.

Is there any closed expression for this variance? Is there anything known about it (will it depend on $U$ and $\mathcal E$, how does it scale with system dimension, etc.)?

As far as I am aware, there is no simple expression for the variance of the average fidelity. However, the sample variance can be computed easily. Suppose you prepared Haar random states and collected the data $\{f_i\}$ then the sample variance is $$s_{N-1}^2 = \frac{1}{N-1}\sum_i (f_i - \bar{f})^2$$ where $$\bar{f} = \frac{1}{N}\sum_i f_i.$$
I should mention one more fact. $$\text{Var}(\bar{F}) \leq O(\frac{1}{N})$$ where D is the dimension of your Hilbert space. This means that if your Hilbert space is large one random state is enough to determine the average fidelity with high probability!