# Trapani test


## A pathological distribution

Because of its fat tail:
\begin{align*}
  \mu_1 &= \text{E}\left[|x|\right] \longrightarrow + \infty  \\
  \mu_2 &= \text{E}\left[|x|^2\right] \longrightarrow + \infty
\end{align*}

. . .

No closed form for parameters $\thus$ numerical estimations

. . .

For a Moyal PDF:
\begin{align*}
  E_M[x] &= \mu + \sigma [ \gamma + \ln(2) ]  \\
  V_M[x] &= \frac{\pi^2 \sigma^2}{2}
\end{align*}


## Infinite moments

- Check whether a moment is finite or infinite
\begin{align*}
  \text{infinite} &\thus Landau \\
  \text{finite}   &\thus Moyal
\end{align*}

. . .


# Trapani test


## Trapani test

::: incremental

  - Random variable $\left\{ x_i \right\}$ sampled from a distribution $f$
  - Sample moments according to $f$ moments
  - $H_0$: $\mu_k \longrightarrow + \infty$
  - Statistic with 1 dof chi-squared distribution

:::


## Trapani test

- Start with $\left\{ x_i \right\}^N$ and compute $\mu_k$ as:
  $$
    \mu_k = \frac{1}{N} \sum_{i = 1}^N |x_i|^k
  $$

. . .

- Generate $r$ points $\left\{ \xi_j\right\}^r$ according to $G(0, 1)$ and define
  $\left\{ a_j \right\}^r$ as:
  $$
    a_j = \sqrt{e^{\mu_k}} \cdot \xi_j
    \thus G'\left( 0, \sqrt{e^{\mu_k}} \right)
  $$

. . .

The greater $\mu^k$, the 'larger' $G'$

- if $\mu_k \longrightarrow + \infty \thus a_j$ distributed uniformly


## Trapani test

- Define the sequence: $\left\{ \zeta_j (u) \right\}^r$ as:
  $$
    \zeta_j (u) = \theta( u -  a_j) \with \theta - \text{Heaviside}
  $$

. . .

\begin{center}
\begin{tikzpicture}
  % line
  \draw [line width=3, ->, cyclamen] (0,0) -- (10,0);
  \node [right] at (10,0) {$u$};
  % tic
  \draw [thick] (5,-0.3) -- (5,0.3);
  \node [above] at (5,0.3) {$u_0$};
  % aj tics
  \draw [thick, cyclamen]          (1,-0.2) -- (1,0.2);
  \node [below right, cyclamen] at (1,-0.2) {$a_{j+2}$};
  \draw [thick, cyclamen]          (2,-0.2) -- (2,0.2);
  \node [below right, cyclamen] at (2,-0.2) {$a_j$};
  \draw [thick, cyclamen]          (5.2,-0.2) -- (5.2,0.2);
  \node [below right, cyclamen] at (5.2,-0.2) {$a_{j+2}$};
  \draw [thick, cyclamen]          (6,-0.2) -- (6,0.2);
  \node [below right, cyclamen] at (6,-0.2) {$a_{j+3}$};
  \draw [thick, cyclamen]          (8.5,-0.2) -- (8.5,0.2);
  \node [below right, cyclamen] at (8.5,-0.2) {$a_{j+4}$};
  % notes
  \node [below] at (1,-1)   {0};
  \node [below] at (2,-1)   {0};
  \node [below] at (5.2,-1) {1};
  \node [below] at (6,-1)   {1};
  \node [below] at (8.5,-1) {1};
  \draw [thick, ->] (1,-0.5)   -- (1,-1);
  \draw [thick, ->] (2,-0.5)   -- (2,-1);
  \draw [thick, ->] (5.2,-0.5) -- (5.2,-1);
  \draw [thick, ->] (6,-0.5)   -- (6,-1);
  \draw [thick, ->] (8.5,-0.5) -- (8.5,-1);
\end{tikzpicture}
\end{center}

. . .

If $a_j$ uniformly distributed and $N \rightarrow + \infty$:

- $\zeta_j (u)$ Bernoulli PDF with $P(\zeta_j (u) = 1) = \frac{1}{2}$


## Trapani test

- Define the function $\vartheta (u)$ as:
$$
  \vartheta (u) = \frac{2}{\sqrt{r}}
                  \left[ \sum_{j} \zeta_j (u) - \frac{r}{2} \right]
$$

. . .

If $a_j$ uniformly distributed and $N \rightarrow + \infty$, for the CLT:
$$
  \sum_j \zeta_j (u) \hence
    G \left( \frac{r}{2}, \frac{r}{4} \right)
  \thus \vartheta (u) \hence
    G \left( 0, 1 \right)
$$

. . .

- Test statistic:
$$
  \Theta = \int_{\underbar{u}}^{\bar{u}} du \, \vartheta^2 (u) \psi(u)
$$


## Trapani test

According to L. Trapani [@trapani15]:

- $r = o(N) \hence r = N^{0.75}$
- $\underbar{u} = 1 \quad \wedge \quad \bar{u} = 1$
- $\psi(u) = \chi_{[\underbar{u}, \bar{u}]}$

. . .

$\mu_k$ must be scale invariant for $k > 1$:

$$
  \tilde{\mu_k} = \frac{\mu_k}{ \left( \mu_{\phi} \right)^{k/\phi} }
  \with \phi \in (0, k)
$$


## Trapani test

If $\mu_k \ne + \infty \hence \left\{ a_j \right\}$ are not uniformly distributed
\vspace{20pt}
Rewriting:
$$
  \vartheta (u) = \frac{2}{\sqrt{r}}
                  \left[ \sum_{j} \zeta_j (u) - \frac{r}{2} \right]
                = \frac{2}{\sqrt{r}}
                  \sum_{j} \left[ \zeta_j (u) - \frac{1}{2} \right]
$$

\vspace{20pt}

Residues become very large $\hence$ $p$-values decreases.
