From 84f42e91c4372e6f540a79bfc57c96c2c8821c4a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 1 Oct 2022 19:51:23 +0000 Subject: proflycee (1oct22) git-svn-id: svn://tug.org/texlive/trunk@64573 c570f23f-e606-0410-a88d-b1316a301751 --- .../doc/latex/proflycee/ProfLycee-doc.pdf | Bin 834268 -> 852659 bytes .../doc/latex/proflycee/ProfLycee-doc.tex | 208 ++++++++++++++++++++- .../texmf-dist/tex/latex/proflycee/ProfLycee.sty | 153 ++++++++++++++- 3 files changed, 350 insertions(+), 11 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf index 9ad760140fe..fb6a67967d1 100644 Binary files a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf and b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf differ diff --git a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex index d653c2ac210..237021230d1 100644 --- a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex +++ b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex @@ -21,9 +21,6 @@ %fancy \fancyhf{} \renewcommand{\headrulewidth}{0pt} -%\lhead{\sffamily \small [ProfLycee]} -%\chead{\entete{\classe{} - \annee}} -%\rhead{\sffamily \small - \thepage{} -} \lfoot{\sffamily \small [ProfLycee]} \cfoot{\sffamily \small - \thepage{} -} \rfoot{\hyperlink{matoc}{\small\faArrowAltCircleUp[regular]}} @@ -60,8 +57,8 @@ \setlength{\parindent}{0pt} \definecolor{LightGray}{gray}{0.9} -\def\PLversion{1.2.6} -\def\PLdate{22 Septembre 2022} +\def\PLversion{1.2.7} +\def\PLdate{1\ier{} Octobre 2022} \tcbset{vignettes/.style={% nobeforeafter,box align=base,boxsep=0pt,enhanced,sharp corners=all,rounded corners=southeast,% @@ -235,6 +232,8 @@ Une commande pour, en \TikZ, créer un pixelart avec correction éventuelle. Une commande pour, en \TikZ, créer un SudoMaths non forcément $9\times9$. +Des commandes pour effectuer des calculs de probas (lois binomiale, exponentielle, de Poisson, normale). + \vspace{1.5cm} \hfill{}\textit{Merci à Anne pour ses retours et sa relecture !} @@ -1536,13 +1535,13 @@ Peu d'options pour ces commandes : \end{codecles} \begin{codetex}[listing only] -\liencapytale{abcd-12345} #lien simple, en sf +\liencapytale{abcd-12345} %lien simple, en sf -\liencapytale[~]{abcd-12345} #lien avec ~ à la fin, en sf +\liencapytale[~]{abcd-12345} %lien avec ~ à la fin, en sf -\liencapytale*{abcd-12345} #lien simple, en tt +\liencapytale*{abcd-12345} %lien simple, en tt -\liencapytale*[~]{abcd-12345} #lien avec ~ à la fin, en tt +\liencapytale*[~]{abcd-12345} %lien avec ~ à la fin, en tt \end{codetex} \begin{codesortie} @@ -3127,7 +3126,7 @@ Cette commande permet de rajouter le point moyen du nuage, calculé par la comma \item \Cle{couleur}, couleur du point moyen ; \hfill~défaut \Cle{red} \item \Cle{style} parmi \Cle{o} (rond) ou \Cle{x} (croix) ou \Cle{+} (plus) ; \hfill~défaut \Cle{o} \item \Cle{xg}, abscisse du point moyen, récupérable via \ctex{PLRegLin} ; \hfill~défaut \Cle{\textbackslash{}LXmoy} - \item \Cle{xy}, abscisse du point moyen, récupérable via \ctex{PLRegLin} ; \hfill~défaut \Cle{\textbackslash{}LYmoy} + \item \Cle{yg}, ordonnée du point moyen, récupérable via \ctex{PLRegLin} ; \hfill~défaut \Cle{\textbackslash{}LYmoy} \item \Cle{nom}, label du point moyen ; \hfill~défaut \Cle{G} \item \Cle{pos} qui est la position du label par rapport au point ; \hfill~défaut \Cle{above} \item \Cle{decal} qui est l'éloignement de la position du label par rapport au point ; \hfill~défaut \Cle{0pt} @@ -3368,6 +3367,193 @@ Sachant que la hauteur par défaut est de 1, il est -- a priori -- intéressant \newpage +\section{Calculs de probabilités}\label{calcprobas} + +\subsection{Introduction} + +\begin{codeidee} +L'idée est de proposer des commandes permettant de calculer des probabilités avec des lois classiques : + +\begin{itemize} + \item binomiale ; + \item normale ; + \item exponentielle ; + \item de Poisson +\end{itemize} +\end{codeidee} + +\begin{codeinfo} +Les commandes sont de deux natures : + +\begin{itemize} + \item des commandes pour calculer, grâce au package \ctex{xintexpr} ; + \item des commandes pour formater le résultat de \ctex{xintexpr}, grâce à \ctex{siunitx}. +\end{itemize} + +De ce fait, les options de \ctex{siunitx} de l'utilisateur affecterons les formatage du résultat, la commande va \og forcer \fg{} les arrondis et l'écriture scientifique. +\end{codeinfo} + +\subsection{Calculs \og simples \fg} + +\begin{codetex}[listing only] +%loi binomiale B(n,p) +\calcPbinomP{n}{p}{k} %P(X=k) +\calcPbinomC{n}{p}{a}{b} %P(a<=X<=b) +%loi de Poisson P (l) +\calcPpoissP{l}{k} %P(X=k) +\calcPpoissC{l}{a}{b} %P(a<=X<=b) +%loi normale N(m,s) +\calcPnormC{m}{s}{a}{b} %P(a<=X<=b) +%loi exponentielle E(l) +\calcPexpoC{l}{a}{b} %P(a<=X<=b) +\end{codetex} + +\begin{codecles} +Les probabilités calculables sont donc -- comme pour beaucoup de modèles de calculatrices -- les probabilités \textbf{P}onctuelles ($P(X=k)$) et \textbf{C}umulées ($P(a\leqslant X\leqslant b)$). + +\smallskip + +Pour les probabilités cumulées, on peut utiliser \ctex{*} comme borne ($a$ ou $b$), pour les probabilités du type $P(X\leqslant b)$ et $P(X \geqslant a)$. +\end{codecles} + +\begin{codetex}[listing only] +% X -> B(5,0.4) +$P(X=3) \approx \calcPbinomP{5}{0.4}{3}$. +$P(X\leqslant1) \approx \calcPbinomC{5}{0.4}{*}{1}$. +% X -> B(100,0.02) +$P(X=10) \approx \calcPbinomP{100}{0.02}{10}$. +$P(15\leqslant X\leqslant25) \approx \calcPbinomC{100}{0.02}{15}{25}$. +% Y -> P(5) +$P(Y=3) \approx \calcPpoissP{5}{3}$. +$P(Y\geqslant2) \approx \calcPpoissC{5}{2}{*}$. +% X -> N(0,1) +$P(X\leqslant1) \approx \calcPnormC{0}{1}{*}{1}$. +$P(-1,96\leqslant Z\leqslant1,96) \approx \calcPnormC{0}{1}{-1.96}{1.96}$. +% X -> N(550,30) +$P(Y\geqslant600) \approx \calcPnormC{550}{30}{600}{*}$. +$P(500\leqslant Y\leqslant600) \approx \calcPnormC{550}{30}{500}{600}$. +% Z -> E(0.001) +$P(Z\geqslant400) \approx \calcPexpoC{0.001}{400}{*}$. +$P(300\leqslant Z\leqslant750) \approx \calcPexpoC{0.001}{300}{750}$. +\end{codetex} + +\begin{codesortie} +$\bullet~~~~X \hookrightarrow \mathcal{B}(5\,;\,0,4)$ :\\ +$P(X=3) \approx \calcPbinomP{5}{0.4}{3}$.\\ +$P(X\leqslant1) \approx \calcPbinomC{5}{0.4}{*}{1}$. + +\medskip + +$\bullet~~~~X \hookrightarrow \mathcal{B}(100\,;\,0,02)$ :\\ +$P(X=10) \approx \calcPbinomP{100}{0.02}{10}$.\\ +$P(15\leqslant X\leqslant25) \approx \calcPbinomC{100}{0.02}{15}{25}$. + +\medskip + +$\bullet~~~~Y \hookrightarrow \mathcal{P}_5$ :\\ +$P(Y=3) \approx \calcPpoissP{5}{3}$.\\ +$P(Y\geqslant2) \approx \calcPpoissC{5}{2}{*}$. + +\medskip + +$\bullet~~~~X \hookrightarrow \mathcal{N}(0\,;\,1)$ :\\ +$P(X\leqslant1) \approx \calcPnormC{0}{1}{*}{1}$.\\ +$P(-1,96\leqslant Z\leqslant1,96) \approx \calcPnormC{0}{1}{-1.96}{1.96}$. + +\medskip + +$\bullet~~~~Y \hookrightarrow \mathcal{N}(550\,;\,30)$ :\\ +$P(Y\geqslant600) \approx \calcPnormC{550}{30}{600}{*}$.\\ +$P(500\leqslant Y\leqslant600) \approx \calcPnormC{550}{30}{500}{600}$. + +\medskip + +$\bullet~~~~Z \hookrightarrow \mathcal{E}_{0,001}$ :\\ +$P(Z\geqslant400) \approx \calcPexpoC{0.001}{400}{*}$.\\ +$P(300\leqslant Z\leqslant750) \approx \calcPexpoC{0.001}{300}{750}$. +\end{codesortie} + +\subsection{Complément avec sortie \og formaté \fg} + +\begin{codeidee} +L'idée est ensuite de formater le résultat obtenu par \ctex{xintexpr}, pour un affichage homogène. + +\smallskip + +L'utilisateur peut donc utiliser \og sa \fg{} méthode pour formater les résultats obtenus par \ctex{xintexpr} ! +\end{codeidee} + +\begin{codetex}[listing only] +%avec un formatage manuel +\num[exponent-mode=scientific]{\calcPbinomP{100}{0.02}{10}} +\end{codetex} + +\begin{codesortie} +$\bullet~~~~X \hookrightarrow \mathcal{B}(100\,;\,0,02)$ : + +$P(X=10) \approx \num[exponent-mode=scientific]{\calcPbinomP{100}{0.02}{10}}$. +\end{codesortie} + +\begin{codeidee} +Le package \ctex{ProfLycee} propose -- en complément -- des commandes pour formater, grâce à \ctex{siunitx}, le résultat. + +Les commandes sont dans ce cas préfixées par \ctex{num} au lieu de \ctex{calc} : + +\begin{itemize} + \item formatage sous forme décimale \textit{pure} : $0,00\ldots$ ; + \item formatage sous forme scientifique : $n,\ldots\times10^{\ldots}$. +\end{itemize} +\end{codeidee} + +\begin{codetex}[listing only] +%loi binomiale B(n,p) +\numPbinomP(*)[prec]{n}{p}{k} %P(X=k) +\numPbinomC(*)[prec]{n}{p}{a}{b} %P(a<=X<=b) +%loi de Poisson P (l) +\numPpoissP(*)[prec]{l}{k} %P(X=k) +\numPpoissC(*)[prec]{l}{a}{b} %P(a<=X<=b) +%loi normale N(m,s) +\numPnormC(*)[prec]{m}{s}{a}{b} %P(a<=X<=b) +%loi exponentielle E(l) +\numPexpoC(*)[prec]{l}{a}{b} %P(a<=X<=b) +\end{codetex} + +\begin{codecles} +Quelques précisions sur les commandes précédentes : + +\begin{itemize} + \item la version étoilée \Cle{*} des commandes formate le résultat en mode scientifique ; + \item l'argument optionnel (par défaut \Cle{3}) correspond à quant à lui à l'arrondi. +\end{itemize} +\end{codecles} + +\begin{codetex}[listing only] +% X -> N(550,30) +$P(Y\geqslant600) \approx \numPnormC[4]{550}{30}{600}{*}$. +$P(500\leqslant Y\leqslant600) \approx \numPnormC[4]{550}{30}{500}{600}$. +% X -> B(100,0.02) +$P(X=10) \approx \numPbinomP[7]{100}{0.02}{10} \approx \numPbinomP*[7]{100}{0.02}{10}$. +$P(15\leqslant X\leqslant25) \approx \numPbinomC[10]{100}{0.02}{15}{25} \approx \numPbinomC*[10]{100}{0.02}{15}{25}$. +\end{codetex} + +\begin{codesortie} +$\bullet~~~~Y \hookrightarrow \mathcal{N}(550\,;\,30)$ : + +$P(Y\geqslant600) \approx \numPnormC[4]{550}{30}{600}{*}$. + +$P(500\leqslant Y\leqslant600) \approx \numPnormC[4]{550}{30}{500}{600}$. + +\medskip + +$\bullet~~~~X \hookrightarrow \mathcal{B}(100\,;\,0,02)$ : + +$P(X=10) \approx \numPbinomP[7]{100}{0.02}{10} \approx \numPbinomP*[7]{100}{0.02}{10}$. + +$P(15\leqslant X\leqslant25) \approx \numPbinomC[10]{100}{0.02}{15}{25} \approx \numPbinomC*[10]{100}{0.02}{15}{25}$. +\end{codesortie} + +\newpage + \section{Conversions binaire/hexadécimal/décimal} \subsection{Idée} @@ -4129,6 +4315,8 @@ La grille, créée en \TikZ, est portée par le rectangle de \og coins \fg{} $(0 \section{Historique} +{\small \bverb|v1.2.7|~:~~~~Ajout de commandes pour des calculs de probabilités (page \pageref{calcprobas}) + {\small \bverb|v1.2.6|~:~~~~Ajout d'un environnement pour des SudoMaths (page \pageref{sudomaths}) {\small \bverb|v1.2.5|~:~~~~Ajout de commandes pour des boîtes à moustaches (page \pageref{boiteamoustaches}) diff --git a/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty b/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty index 7fdd37b256c..708ef7b8130 100644 --- a/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty +++ b/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty @@ -3,7 +3,8 @@ % or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{ProfLycee}[2022/09/22 v1.2.6 - Aide pour l'utilisation de LaTeX en lycee] +\ProvidesPackage{ProfLycee}[2022/10/01 v1.2.7 - Aide pour l'utilisation de LaTeX en lycee] +% 1.2.7 Calculs de probas pour des lois classiques % 1.2.6 Ajout d'un environnement tikz pour des sudomaths personnalisés % 1.2.5 Ajout d'une commande pour des boites à moustaches, en tikz % 1.2.4 Correction de quelques bugs mineurs, et mise à jour de la doc @@ -2179,4 +2180,154 @@ \end{tikzpicture} } +%================LOISPROBAS============ OK !! +%calculs "simples" +\newcommand\calcPbinomP[3]{%npk + \xintFloatToDecimal{\xintfloateval{binomial(#1,#3)*#2^#3*(1-#2)^(#1-#3)}} +} +\newcommand\calcPbinomC[4]{%npab + \def\BorneInf{#3}\def\BorneSup{#4} + \ifthenelse{\equal{#3}{*}}% + {\def\BorneInf{0}} + {} + \ifthenelse{\equal{#4}{*}}% + {\def\BorneSup{#4}} + {} + \xintFloatToDecimal{\xintfloateval{add(binomial(#1,i)*#2^i*(1-#2)^(#1-i), i=\BorneInf..\BorneSup)}} +} +\newcommand\calcPpoissP[2]{%lk + \xintFloatToDecimal{\xintfloateval{exp(-#1)*#1^#2/factorial(#2)}} +} +\newcommand\calcPpoissC[3]{%lab + \def\BorneInf{#2}\def\BorneSup{#3} + \ifthenelse{\equal{#2}{*}}% + {\def\BorneInf{0}} + {} + \ifthenelse{\equal{#3}{*}}% + {\def\BorneSup{10*#1}} + {} + \xintFloatToDecimal{\xintfloateval{add(exp(-#1)*#1^i/factorial(i), i=\BorneInf..\BorneSup)}} +} +%utiles idée de https://tex.stackexchange.com/questions/355574/im-searching-for-a-table-with-cdf-of-standard-normal-distribution +\xintdeffloatvar a_1,a_2,a_3,a_4,a_5,a_6 := +0.0705230784,0.0422820123,0.0092705272,0.0001520143,0.0002765672,0.0000430638; +\xintdeffloatvar rac2inv := sqrt(2)/2 ; +\xintdeffloatfunc erfc(x) := % uniquement pour x positif +((((((a_6*x+a_5)*x+a_4)*x+a_3)*x+a_2)*x+a_1)*x+1)**-16 ; % fin de définition de erfc(x) +\xintdeffloatfunc Phi(z) := (z>=0)?{1 - 0.5 * erfc(rac2inv * z)}{0.5 * erfc(-rac2inv * z)}; + +\newcommand\calcPnormC[4]{%msab + %def des bornes de l'intervalle suivant l'absence de a ou de b... + \def\BorneInf{#3}\def\BorneSup{#4} + \ifthenelse{\equal{#3}{*}}% + {\def\BorneInf{#4-10*#2}} + {} + \ifthenelse{\equal{#4}{*}}% + {\def\BorneSup{#3+10*#2}} + {} + \xintFloatToDecimal{\xintfloateval{Phi((\BorneSup-#1)/#2)-Phi((\BorneInf-#1)/#2)}} +} +%calculs "simples" fiabilite +\newcommand\calcPexpoC[3]{%lab + \def\BorneInf{#2}\def\BorneSup{#3} + \ifthenelse{\equal{#2}{*}}% + {\def\BorneInf{0}} + {} + \ifthenelse{\equal{#3}{*}}% + {\def\BorneSup{100/#1}} + {} + \xintFloatToDecimal{\xintfloateval{exp(-#1*\BorneInf)-exp(-#1*\BorneSup)}} +} + +%calculs formatés +\NewDocumentCommand{\numPbinomP}{ s O{3} m m m }{%*=sci,2=prec,3=n,4=p,5=k + \IfBooleanTF{#1}% + {% + \num[exponent-mode=scientific]{\xintFloatToDecimal{\xintfloateval{round(binomial(#3,#5)*#4^#5*(1-#4)^(#3-#5),#2)}}} + }% + {% + \num[minimum-decimal-digits=#2]{\xintFloatToDecimal{\xintfloateval{round(binomial(#3,#5)*#4^#5*(1-#4)^(#3-#5),#2)}}} + } +} + +\NewDocumentCommand{\numPbinomC}{ s O{3} m m m m }{%*=sci,2=prec,3=n,4=p,5=a,6=b + \def\BorneInf{#5}\def\BorneSup{#6} + \ifthenelse{\equal{#5}{*}}% + {\def\BorneInf{0}} + {} + \ifthenelse{\equal{#6}{*}}% + {\def\BorneSup{#3}} + {} + \IfBooleanTF{#1}% + {% + \num[exponent-mode=scientific]{\xintFloatToDecimal{\xintfloateval{round(add(binomial(#3,i)*#4^i*(1-#4)^(#3-i), i=\BorneInf..\BorneSup),#2)}}} + }% + {% + \num[minimum-decimal-digits=#2]{\xintFloatToDecimal{\xintfloateval{round(add(binomial(#3,i)*#4^i*(1-#4)^(#3-i), i=\BorneInf..\BorneSup),#2)}}} + } +} + +\NewDocumentCommand{\numPpoissP}{ s O{3} m m }{%*=sci,2=prec,3=lbda,4=k + \IfBooleanTF{#1}% + {% + \num[exponent-mode=scientific]{\xintFloatToDecimal{\xintfloateval{round(exp(-#3)*#3^#4/factorial(#4),#2)}}} + }% + {% + \num[minimum-decimal-digits=#2]{\xintFloatToDecimal{\xintfloateval{round(exp(-#3)*#3^#4/factorial(#4),#2)}}} + } +} + +\NewDocumentCommand{\numPpoissC}{ s O{3} m m m }{%*=ing,2=prec,3=lbda,4=a,5=b + \def\BorneInf{#4}\def\BorneSup{#5} + \ifthenelse{\equal{#4}{*}}% + {\def\BorneInf{0}} + {} + \ifthenelse{\equal{#5}{*}}% + {\def\BorneSup{10*#3}} + {} + \IfBooleanTF{#1}% + {% + \num[exponent-mode=scientific]{\xintFloatToDecimal{\xintfloateval{round(add(exp(-#3)*#3^i/factorial(i), i=\BorneInf..\BorneSup),#2)}}} + }% + {% + \num[minimum-decimal-digits=#2]{\xintFloatToDecimal{\xintfloateval{round(add(exp(-#3)*#3^i/factorial(i), i=\BorneInf..\BorneSup),#2)}}} + } +} + +\NewDocumentCommand{\numPnormC}{ s O{3} m m m m }{% + %*=ing,2=prec,3=mu,4=sigma,5=a,6=b + %def des bornes de l'intervalle suivant l'absence de a ou de b... + \def\BorneInf{#5}\def\BorneSup{#6} + \ifthenelse{\equal{#5}{*}}% + {\def\BorneInf{#6-10*#4}} + {} + \ifthenelse{\equal{#6}{*}}% + {\def\BorneSup{#5+10*#4}} + {} + \IfBooleanTF{#1}% + {% + \num[exponent-mode=scientific]{\xintFloatToDecimal{\xintfloateval{round(Phi((\BorneSup-#3)/#4)-Phi((\BorneInf-#3)/#4),#2)}}} + }% + {% + \num[minimum-decimal-digits=#2]{\xintFloatToDecimal{\xintfloateval{round(Phi((\BorneSup-#3)/#4)-Phi((\BorneInf-#3)/#4),#2)}}} + } +} + +\NewDocumentCommand{\numPexpoC}{ s O{3} m m m }{%*=ing,2=prec,3=lbda,4=a,5=b + \def\BorneInf{#4}\def\BorneSup{#5} + \ifthenelse{\equal{#4}{*}}% + {\def\BorneInf{0}} + {} + \ifthenelse{\equal{#5}{*}}% + {\def\BorneSup{100/#3}} + {} + \IfBooleanTF{#1}% + {% + \num[exponent-mode=scientific]{\xintFloatToDecimal{\xintfloateval{round(exp(-#3*\BorneInf)-exp(-#3*\BorneSup),#2)}}} + }% + {% + \num[minimum-decimal-digits=#2]{\xintFloatToDecimal{\xintFloatToDecimal{\xintfloateval{round(exp(-#3*\BorneInf)-exp(-#3*\BorneSup),#2)}}}} + } +} + \endinput \ No newline at end of file -- cgit v1.2.3