Source Latex
\documentclass[12pt,onecolumn,a4paper]{article}
\usepackage[french]{babel}
%\selectlanguage{francais}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{enumerate}
\usepackage{array}
\usepackage{calc}
\usepackage{pst-all}
\usepackage{hyperref}
\hypersetup{
pdfauthor={Yoann Morel},
pdfsubject={Algorithmique et programmation - Simulation de l'aléatoire},
pdftitle={Simulation de l'aléatoire - Estimation de probabilités},
pdfkeywords={algorithme, algorithmique, estimation, simulation, programmation, probabilités, Mathématiques}
}
\hypersetup{
colorlinks = true,
linkcolor = red,
anchorcolor = red,
citecolor = blue,
filecolor = red,
urlcolor = red
}
\voffset=-1cm
% Raccourcis diverses:
\newcommand{\nwc}{\newcommand}
\nwc{\dsp}{\displaystyle}
\nwc{\bge}{\begin{equation}}\nwc{\ene}{\end{equation}}
\nwc{\bgar}{\begin{array}}\nwc{\enar}{\end{array}}
\nwc{\bgit}{\begin{itemize}}\nwc{\enit}{\end{itemize}}
\nwc{\bgen}{\begin{enumerate}}\nwc{\enen}{\end{enumerate}}
\nwc{\la}{\left\{}\nwc{\ra}{\right\}}
\nwc{\lp}{\left(}\nwc{\rp}{\right)}
\nwc{\lb}{\left[}\nwc{\rb}{\right]}
\nwc{\ul}{\underline}
\nwc{\tm}{\times}
\nwc{\V}{\overrightarrow}
\newcommand{\zb}{\mbox{$0\hspace{-0.67em}\mid$}}
\newcommand{\db}{\mbox{$\hspace{0.1em}|\hspace{-0.67em}\mid$}}
\newcommand{\ct}{\centerline}
\nwc{\bgsk}{\bigskip}
\nwc{\vsp}{\vspace{0.1cm}}
\nwc{\vspd}{\vspace{0.2cm}}
\nwc{\vspt}{\vspace{0.3cm}}
\nwc{\vspq}{\vspace{0.4cm}}
\def\N{{\rm I\kern-.1567em N}}
\def\D{{\rm I\kern-.1567em D}}
\def\R{{\rm I\kern-.1567em R}}
\def\C{{\rm C\kern-4.7pt
\vrule height 7.7pt width 0.4pt depth -0.5pt \phantom {.}}}
\def\Q{\mathbb{Q}}
\def\Z{{\sf Z\kern-4.5pt Z}}
\def\euro{\mbox{\raisebox{.25ex}{{\it =}}\hspace{-.5em}{\sf C}}}
% Concernant la mise en page des algo:
\definecolor{grayp}{gray}{0.8}
\definecolor{graypc}{gray}{0.65}
\newlength{\ProgIndent}
\setlength{\ProgIndent}{0.6cm}
\nwc{\PI}{\hspace*{\ProgIndent}}
\nwc{\DPI}{\hspace*{2\ProgIndent}}
\nwc{\TPI}{\hspace*{3\ProgIndent}}
\nwc{\QPI}{\hspace*{4\ProgIndent}}
\newlength{\lgcoin}\setlength{\lgcoin}{3ex}
\newlength{\lgshadow}\setlength{\lgshadow}{0.5ex}
\newlength{\phgn}\newlength{\phgnp}
\newlength{\phgng}
\newlength{\plgn}\newlength{\plgng}
\newlength{\phgtq}\newlength{\phgtqg}
\newlength{\plgtq}\newlength{\plgtqg}
\newlength{\plgcoin}\setlength{\plgcoin}{3ex}
\newlength{\plgshadow}\setlength{\plgshadow}{0.5ex}
\newlength{\wTitle}\newlength{\toleft}\newlength{\ww}
\nwc{\Prog}[3]{%
%\par\vspd%
\setlength{\ww}{#2}
\settowidth{\wTitle}{#1}%\setlength{wTitle}
\addtolength{\ww}{-\wTitle}
\bgmp[t]{#2+0.5cm}%\linewidth}
\hspace*{-0.3pt}\hspace*{-\parindent}\hspace*{-1ex}%
\hspace{\ww}\psframebox[fillstyle=solid,fillcolor=graypc]{
\emph{\textcolor{white}{\!\!#1}}} \\
\vspace*{-0.5ex}\\
\bgmp{#2}
%\setlength{\fboxrule}{0.1pt}
\settototalheight{\phgn}{\phantom{\bgmp{#2}#3\enmp}}
\setlength{\phgn}{\phgn-2ex}
\setlength{\plgn}{\linewidth}
\setlength{\phgtq}{-\phgn}%\addtolength{\hgtq}{-3ex}
\setlength{\phgtqg}{\phgtq}\addtolength{\phgtqg}{-\lgshadow}
\setlength{\plgng}{\plgn}\addtolength{\plgng}{\lgshadow}
\setlength{\plgtq}{\plgn}\addtolength{\plgtq}{-\lgcoin}
\setlength{\plgtqg}{\plgtq}\addtolength{\plgtqg}{\lgshadow}
\setlength{\phgnp}{\phgn}\addtolength{\phgnp}{\lgcoin}
\setlength{\phgng}{\phgnp}\addtolength{\phgng}{\lgshadow}
\pspolygon[linecolor=white,fillstyle=solid,fillcolor=grayp]%
(-1ex,-\phgnp)(-1ex,1ex)(\plgn,1ex)(\plgng,0)%
(\plgng,\phgtqg)(\plgtqg,-\phgng)(-0.5ex,-\phgng)
\pspolygon[linewidth=0.6pt,linecolor=graypc,fillstyle=solid,fillcolor=graypc]%
(\plgn,\phgtq)(\plgtq,\phgtq)(\plgtq,-\phgnp)
\pspolygon[fillstyle=solid,fillcolor=white]%
(-1ex,-\phgnp)(-1ex,1ex)(\plgn,1ex)%
(\plgn,\phgtq)(\plgtq,\phgtq)(\plgtq,-\phgnp)
\par
\bgmp{\linewidth}#3\enmp
\enmp\enmp%
}
% et pour les progs casio:
\nwc{\return}{
\psset{unit=1cm,arrowsize=4pt}
\psline{<-}(0,0.1)(0.3,0.1)(0.3,0.25)}
\nwc{\disp}{\pspolygon[fillstyle=solid,fillcolor=black](0,0)(0.2,0)(0.2,0.15)}
%%%%
\newcounter{nex}[section]\setcounter{nex}{0}
\newenvironment{EX}{%
\stepcounter{nex}
\bgsk{\noindent{{\bf Exercice }}\arabic{nex}}\hspace{0.5cm}
}{}
\nwc{\bgex}{\begin{EX}}\nwc{\enex}{\end{EX}}
\nwc{\bgmp}{\begin{minipage}}\nwc{\enmp}{\end{minipage}}
\newenvironment{centerpage}{\vspace*{\fill}}{
\protect\vspace*{\fill}}
\setlength{\columnsep}{30pt} % default=10pt
\setlength{\columnseprule}{1pt} % default=0pt (no line)
\setlength{\headsep}{0in} % default=0.35in
\setlength{\parskip}{0ex}
\setlength{\parindent}{0mm}
\voffset=-1cm
\textheight=26.8cm
\textwidth=18.6cm
\topmargin=0cm
\headheight=-0.cm
\footskip=1.cm
\oddsidemargin=-1.5cm
\nwc{\TITLE}{Simulation de l'aléatoire - Estimation de probabilités}
\title{\TITLE}
\date{}
\author{}
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\setlength{\headheight}{0cm}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{.1pt}
\lhead{}\chead{}\rhead{}
\lfoot{Y. Morel - \url{xymaths.free.fr/Lycee/1S/}}
\rfoot{\TITLE\ - \thepage/\pageref{LastPage}}
\cfoot{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%\thispagestyle{empty}
%\maketitle
\ct{\LARGE{\TITLE}}
\paragraph{Un algorithme / programme de base}\
\vspace{-1.2em}
\bgmp{6cm}
Exécuter l'algorithme ci-contre pour $N=5$. \\[1em]
Qu'affiche-t'il en sortie ? \\
\`A quoi sert-il ?
\enmp\qquad
\bgmp{12cm}
\Prog{Algorithme}{12cm}{
\texttt{Demander N \\
Affecter 0 à S \\
Pour I de 1 à N\\
\PI Affecter un nombre entier aléatoire entre 1 et 6 à D\\
\PI Si D=6\\
\DPI Affecter S+1 à S\\
\PI Fin Si\\
Fin Pour\\
Afficher S/N
}
}
\enmp
\medskip
\textbf{Indications de programmation}
\begin{description}
\item[TI:] Dans le menu \texttt{math}, puis probabilités (\texttt{PROB}),
la fonction \texttt{nbrAléatEnt(p,q)} permet de tirer un nombre entier
au hasard entre \texttt{p} et \texttt{q}.
\item[Python:] Il faut charger la fonction \texttt{randint}
depuis une bibliothèque de fonctions mathématiques: \\
\mbox{\texttt{"from random import randint"}} , en tout début de programme;
ensuite la commande \texttt{randint(p,q)} permet de tirer un
nombre entier entre \texttt{p} et \texttt{q} au hasard.
\end{description}
\paragraph{\large Quelques problèmes à simuler} \
\paragraph{Lancer de deux dés - }
On lance deux dés bien équilibrés dont les faces sont numérotées de 1 à 6.
On ajoute alors les deux chiffres obtenus.
Estimer à l'aide d'un programme la probabilité d'obtenir 6.
\paragraph{Politique de naissances - }
Dans un pays fictif, on impose la loi de naissance suivante:
chaque couple peut avoir au maximum quatre enfants
et ne peut avoir qu'un seul garçon.
Estimer la proportion filles / garçons dans ce pays.
\paragraph{Méthode Monté Carlo pour le calcul d'aire}
On considère le quart de disque grisé ci-contre.
\medskip
\bgmp{14cm}
\bgen
\item On tire deux nombres, $x$ et $y$, au hasard dans $[0;1]$. \\
\`A quelle condition le point $M(x;y)$ est-il dans le quart de disque ?
\item \'Ecrire un programme qui demande un nombre $N$
puis tire $N$ couples de nombres $x$ et $y$ et qui compte
le nombre $D$ de ces couples pour lequel $M(x;y)$ est un point du quart de
disque.
\medskip
Afficher la valeur $4\tm\dfrac{D}{N}$ pour des valeurs de $N$
de plus en plus grande.
Que remarque-t'on ? \'Etait-ce prévisible ?
\enen
\enmp\hfill
\bgmp{5.5cm}
\psset{unit=3.4cm,arrowsize=7pt}
\begin{pspicture}(-0.2,0.1)(1.2,1.)
\nwc\g[1]{1 #1 #1 mul sub 0.5 exp}
%
\pscustom{
\psplot[plotpoints=100]{0}{1}{\g{x}}\gsave
\psline(1,0)(0,0)
\fill[fillstyle=solid,fillcolor=gray]
\grestore}
%
\psline{->}(-0.1,0)(1.2,0)
\psline{->}(0,-0.1)(0,1.2)
\psline(0,1)(1,1)(1,0)
\rput(-0.08,-0.08){$O$}
\rput(1,-0.08){$1$}\rput(-0.08,1){$1$}
\end{pspicture}
\enmp
\bgmp{14cm}
Reprendre la démarche précédente pour estimer
l'aire du domaine grisé sur la figure ci-contre,
et qui est sous la courbe représentative de la fonction $f$
définie par $f(x)=x^2$.
\enmp\hfill
\bgmp{5.5cm}
\psset{unit=3.4cm,arrowsize=7pt}
\begin{pspicture}(-0.2,0.1)(1.3,1.4)
\nwc\f[1]{#1 #1 mul}
%
\pscustom{
\psplot[plotpoints=100]{0}{1}{\f{x}}\gsave
\psline(1,0)(0,0)
\fill[fillstyle=solid,fillcolor=gray]
\grestore}
%
\psline{->}(-0.1,0)(1.2,0)
\psline{->}(0,-0.1)(0,1.2)
\psline(0,1)(1,1)(1,0)
\rput(-0.08,-0.08){$O$}
\rput(1,-0.08){$1$}\rput(-0.08,1){$1$}
\end{pspicture}
\enmp
\label{LastPage}
\end{document}
Télécharger le fichier source