Académique Documents
Professionnel Documents
Culture Documents
AHMED EL KHARROUBI
1. ∀a, b, 0 ≤ a < b ≤ 1
P(U ∈ [a, b]) = b − a
Exemple 3 1.
X = [rand() ∗ 6] + 1
2.
X = [rand(1, 5) ∗ 6] + 1
3.
X = [U1 ∗ 3] ∗ [U2 ∗ 2]
1
Ahmed El kharroubi fsac Casablanca
on a
F −1 (u) = (1 + u)1[0,1] (u)
on a :
Ln(1 − u)
F −1 (u) = (− )1[0,1[ (u)
λ
Proposition 7 Soit X une variable aléatoire de fonction de répartition F .
Soit U = rand(). On pose Y = F −1 (U ). Alors les variables X et Y obéissent
à la même loi. Ainsi F −1 (rand()) simule une valeur de X
X ← a + (b − a) ∗ rand()
ln(rand())
X← −
λ
3. Variable discrète
Proposition 10 Soit X une variable aléatoire telle que X(Ω) = {x0 , x1 , ..., xn }
et, pi = P(X = xi ). Rappelons que pi ≥ 0 et que
n
X
pi = 1
i=0
2
Ahmed El kharroubi fsac Casablanca
et
n
X
−1
F (u) = x0 1[0,p0 [ (u) + xi 1[Pk−1 pi ,Pk pi [ (u)
i=0 i=0
k=1
Pogramme Scilab :
function y=sdiscrete(x,p)
#x= vecteur des valeurs prises par la variable aléatoire X
#p= vecteur des probabilités
u=rand(); q=p(0); i=0;
while (u>q); i=i+1; q=q+p(i); end;
y=x(i);
4. Loi BINOMIALE
function y=binomiale(n,p)
u=rand();
P=zeros(1,n+1);
P=binomial(p,n);
q=P(1);
i=0;
while(u>q); i=i+1; q=q+P(i+1);
end;
y=i;
endfunction
5. Loi Géometrique
function x=geometrique(p)
x=1;
while(rand()>p), x=x+1;
end;
endfunction
Proposition 11
ln(rand())
X =1+[ ]
ln(1 − p)
suit la loi geometrique de parametre p
3
Ahmed El kharroubi fsac Casablanca
6. Loi de Poisson
function x=lpoisson(l)
u=rand();
q=exp(-l);
i=0;
while(u>q), i=i+1;q=q*(1+l/(i+1));
end;
x=i;
endfunction
function x=poisson(l)
q=exp(-l);
x=0;
p=rand();
while(p>q), x=x+1;p=p*rand();
end;
endfunction
{(x, y)|x2 + y 2 ≤ 1}
ou
Comment choisir un point au hasard dans le disque unité ?
4
Ahmed El kharroubi fsac Casablanca
function [a]=disque(n)
for k=1:n
xy=[1,2];
while(xy(1)^2+xy(2)^2>1),
plot(xy(1),xy(2),’.b’);
xy=6*rand(1,2)-[3,3];
end;
a=xy;
plot(xy(1),xy(2),’.r’)
end;
endfunction
cours-simulation-soms-s2/home/choix-point-disque-eps-converted-to.pdf
∀x ∈ [a, b] : f (x) ≤ M
Exemple 16
f (x) = 6x(1 − x)1[0,1] (x)
5
Ahmed El kharroubi fsac Casablanca
∀x ∈ R f (x) ≤ Kg(x)
On pose
f (y)
α(y) =
kg(y)
Soit ((Xn , Yn ))n une suite i.i.d telle que Yn est une var de loi uniforme :
U[0,1] et Xn une var de densité g
function x=simulf
u=rand(); z=simulg;
y=K*u*g(z);
while(y>=f(z)), u=rand(); z=simulg;
y=K*u*g(z);
end;
endfunction
Exemple 18
3
f (x) = Ce−x 1R+ (x)
function X=melange(N,p,mu1,mu2)
Y=grand(1,N,"bin",1,p);
Z1=grand(1,N,"exp",mu1);
Z2=grand(1,N,"exp",mu2);
X=Y.*Z1+(1-Y).*Z2;
endfunction
X = 1{Θ=1} X1 + 1{Θ=−1} X2
6
Ahmed El kharroubi fsac Casablanca
Théorème 22 (Loi forte des grands nombres) Soit X une variable aléatoire
tel que E(|X|) < +∞. Soit (Xi )i une suite de réalisations de X ( c’est
indépendantes et de même loi que X). Alors on P − p.s
Pn
i=1 Xi
lim = E(X)
n→+∞ n
7
Ahmed El kharroubi fsac Casablanca