# Moyal distribution


## Moyal PDF


Standard form:
$$
  M(z) = \frac{1}{\sqrt{2 \pi}} \exp
         \left[ - \frac{1}{2} \left( z + e^{-z} \right) \right]
$$

. . .

More generally:

   - location parameter $\mu$
   - scale parameter $\sigma$

$$
  z = \frac{x - \mu}{\sigma}
  \thus
  M_{\mu \sigma}(x) = \frac{1}{\sqrt{2 \pi} \sigma} \exp
         \left[ - \frac{1}{2} \left(
           \frac{x - \mu}{\sigma}
           + e^{-\frac{x - \mu}{\sigma}} \right) \right]
$$


## Moyal CDF

The CDF $F_M(x)$ can be derived by direct integration:
$$
  F_M(x) = \int\limits_{- \infty}^x dy \, M(y)
  = \frac{1}{\sqrt{2 \pi}} \int\limits_{- \infty}^x dy \, e^{- \frac{y}{2}}
  e^{- \frac{1}{2} e^{-y}}
$$

. . .

With the change of variable $z = e^{-\frac{y}{2}}/\sqrt{2}$:
$$
  F_M(x) =
  \frac{-2 \sqrt{2}}{\sqrt{2 \pi}} \int\limits_{+ \infty}^{f(x)} dz \, e^{- z^2}
  \with f(x) = \frac{e^{- \frac{x}{2}}}{\sqrt{2}}
$$


## Moyal CDF

Remembering the error function
$$
  \text{erf}(x) = \frac{2}{\sqrt{\pi}} \int_0^x dy \, e^{-y^2}
$$
one finally gets:
$$
  F_M(x) = 1 - \text{erf} \left( \frac{e^{- \frac{x}{2}}}{\sqrt{2}} \right)
$$


## Moyal QDF

The quantile (CDF\textsuperscript{-1}) is found solving for $x$:
$$
  y = 1 - \text{erf} \left( \frac{e^{- \frac{x}{2}}}{\sqrt{2}} \right)
$$
hence:
$$
  Q_M(y) = -2 \ln \left[ \sqrt{2} \, \text{erf}^{-1} (1 - y) \right]
$$


## Moyal median

Defined by $F(m) = \frac{1}{2}$ or $m = Q \left( \frac{1}{2} \right)$:

\begin{align*}
  M(z)
    &\thus m_M\ex = -2 \ln \left[ \sqrt{2} \,
    \text{erf}^{-1} \left( \frac{1}{2} \right) \right] \\
  M_{\mu \sigma}(x)
    &\thus m_M\ex = \mu -2 \sigma \ln \left[ \sqrt{2} \,
    \text{erf}^{-1} \left( \frac{1}{2} \right) \right]
\end{align*}

\setbeamercovered{}

\begin{center}
  \begin{tikzpicture}[overlay]
    \pause
    \node [opacity=0.5, xscale=0.55, yscale=0.4 ] at (1.85,1.1) {\includegraphics{images/high.png}};
  \end{tikzpicture}
\end{center}

\setbeamercovered{transparent}

## Moyal mode

Peak of the PDF:
$$
  \partial_x M(x) = \partial_x \left( \frac{1}{\sqrt{2 \pi}} e^{-\frac{1}{2}
                    \left( x + e^{-x} \right)} \right)
                  = \frac{1}{\sqrt{2 \pi}} e^{-\frac{1}{2}
                    \left( x + e^{-x} \right)} \left( -\frac{1}{2} \right)
                    \left( 1 - e^{-x} \right)
$$

\begin{align*}
  \partial_x M(z) = 0 &\thus \mu_M\ex = 0                \\
  \partial_x M_{\mu \sigma}(x) = 0 &\thus \mu_M\ex = \mu \\
\end{align*}

\setbeamercovered{}

\begin{center}
  \begin{tikzpicture}[overlay]
    \pause
    \node [opacity=0.5, xscale=0.18, yscale=0.25 ] at (2.4,1.8) {\includegraphics{images/high.png}};
  \end{tikzpicture}
\end{center}

\setbeamercovered{transparent}

## Moyal FWHM

We need to compute the maximum value:
$$
  M(\mu) = \frac{1}{\sqrt{2 \pi e}} \thus M(x_{\pm}) = \frac{1}{\sqrt{8 \pi e}}
$$

. . .

which leads to:
$$
  x_{\pm} + e^{-x_{\pm}} = 1 + 2 \ln(2) \thus
  \begin{cases}
    x_+ = 1 + 2 \ln(2) + W_0 \left( - \frac{1}{4 e} \right)    \\
    x_- = 1 + 2 \ln(2) + W_{-1} \left( - \frac{1}{4 e} \right)
  \end{cases}
$$

## Moyal FWHM

$$
  x_+ - x_- = 3.590806098... = a
$$
\begin{align*}
  M(z)
    &\thus w_M^{\text{exp}} = a              \\
  M_{\mu \sigma}(x)
    &\thus w_M^{\text{exp}} = \sigma \cdot a \\
\end{align*}

\setbeamercovered{}

\begin{center}
  \begin{tikzpicture}[overlay]
    \pause
    \node [opacity=0.5, xscale=0.2, yscale=0.25 ] at (1.9,1.9) {\includegraphics{images/high.png}};
  \end{tikzpicture}
\end{center}

\setbeamercovered{transparent}