%========================= Loi binomiale ==========================
\begin{VerbatimOut}{LoiBinomiale.cxx}
 local k,T,x,y;
 T:="\\begin{center}\\begin{tikzpicture}[yscale=20,xscale=0.5]\\draw[thick,->] (0,0) -- (21,0) node[right] {$k$};\\draw[thick,->] (0,0) -- (0,0.25) node[right] {$\\probavar{X}{k}$};\\foreach \\y in {0.05,0.1,0.15,0.2}\\draw[gray!20] (20,\\y) -- (0,\\y) node[black,left,scale=0.8] {\\y};"; 
 
 for (k:=0;k<=20;k++)
 {
	y:=binomial(20,k,0.3);
	x:=k+0.2;
	xx:=k+0.5;
	T:=T+"\draw ("+k+",0.05)--("+k+",-0.05);\\node[below,scale=0.8] at ("+xx+",0) {"+k+"};\\fill[green!50!black] ("+x+",0) rectangle+(0.6,"+latex(y)+");";
 };
 T:=T+"\\end{tikzpicture}\\\\\\textbf{Cas ou $\\pmb{n=20}$ et $\\pmb{p=0,3}$}\\end{center}";

 Sortie:=fopen("graphiqueLoiBinomiale.tex");
 Resultat:=cat(T);
 fprint(Sortie,Unquoted,Resultat);
 fclose(Sortie);
\end{VerbatimOut}

\newenvironment{LoiBinomiale}
{\VerbatimEnvironment\begin{VerbatimOut}{LoiBinomiale.txt}}
{\end{VerbatimOut}
\immediate\write18{giac < LoiBinomiale.cxx}
\immediate\write18{giac  LoiBinomiale.cxx}
\input{graphiqueLoiBinomiale}
}
