% Copyright (c)  2010-2011  EADS.
% Permission is granted to copy, distribute and/or modify this document
% under the terms of the GNU Free Documentation License, Version 1.2
% or any later version published by the Free Software Foundation;
% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
% Texts.  A copy of the license is included in the section entitled "GNU
% Free Documentation License".




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
\section{Examples Guide}

This section presents some full-length examples of studies using the module.

\subsection{Test case presentation}

In this test case, we create a sample from a mixture and we try to estimate the mixture parameters from the sample. It is not a really an example of a study but it shows how to use this module.

The optimal number of clusters is not supposed to be known, and will be estimated as well.

We are in dimension 2, and the reference mixture is defined from 3 normal distributions:
\begin{equation*}
 f(x) = \alpha_1 f_1(x) + \alpha_2 f_2(x) + \alpha_3 f_3(x)
\end{equation*}
with
\begin{itemize}
 \item $f_1=N(\mu_1,\sigma_1,R_1)$ with $\mu_1=(-2.2,-2.2)$, $\sigma_1=(1.2,1.2)$, $R_1=\begin{pmatrix}1 & -0.2 \\ -0.2 & 1\end{pmatrix}$ and $\alpha_1 = 0.5$,
 \item $f_2=N(\mu_2,\sigma_2,R_2)$ with $\mu_2=(2,2)$, $\sigma_2=(0.8, 0.8)$, $R_2=\begin{pmatrix}1 & 0.1 \\ 0.1 & 1\end{pmatrix}$ and $\alpha_2 = 0.25$,
 \item $f_3=N(\mu_3,\sigma_3,R_3)$ with $\mu_3=(-5,5)$, $\sigma_3=(1.4,1.4)$, $R_3=\begin{pmatrix}1 & 0. \\ 0. & 1\end{pmatrix}$ and $\alpha_3 = 0.25$.
\end{itemize}



Then we print the parameters of the mixture (more precisely the distributions of the collection to build this mixture) and we can see that it is similar. We obtain the following distributions :
\begin{itemize}
 \item $\hat{f}_1=N(\mu_1,\sigma_1,R_1)$ with $\mu_1=(-2.215,-2.197)$, $\sigma_1=(1.168,1.163)$,  $R_1=\begin{pmatrix}1 & -0.137 \\ -0.137 & 1\end{pmatrix}$ and $\alpha_1 = 0.498$,
 \item $\hat{f}_2=N(\mu_2,\sigma_2,R_2)$ with $\mu_2=(1.958,2.009)$, $\sigma_2=(1.175,1.156)$, $R_2=\begin{pmatrix}1 & 0.136 \\ 0.136 & 1\end{pmatrix}$ and $\alpha_2 = 0.255$,
 \item $\hat{f}_3=N(\mu_3,\sigma_3,R_3)$ with $\mu_3=(-5.020,5.005)$, $\sigma_3=(1.107,1.221)$, $R_3=\begin{pmatrix}1 & 0.096 \\ 0.096 & 1\end{pmatrix}$ and $\alpha_3 = 0.246$,
\end{itemize}



The drawing obtained in this example (with 2000 points) is on figure \ref{fig:showMixmodResult}.




\subsection{Python script}

\lstinputlisting[language=Python]{script_2DMixture.py}
