algoimportants.py

Created by raph-couvert

Created on November 06, 2025

1.85 KB


gene congruentiel lineaire

Entrée : a, c, m, x0 (seed)
Sortie : suite Ui uniformes sur [0,1]

Pour i = 1 à N :
    xi+1 = (a*xi + c) mod m
    Ui = xi / m
Fin


methode transfo inverse

Entrée : U ~ Unif[0,1], F(x) = P(X  x)
Sortie : X ~ F

X = F1(U)


methode accepation rejet

Etape 1 : Générer X selon densité g(x)
Etape 2 : Générer U ~ Unif(0,1)
Si U  f(X)/(c*g(X)) :
    accepter X
Sinon :
    rejeter et recommencer




methode box muller
gene loi normales

Générer U1, U2 ~ Unif[0,1]
R = (-2 ln U1)
θ = 2πU2
Z1 = R cos(θ)
Z2 = R sin(θ)
Retourne Z1, Z2 ~ N(0,1)


decomposition cholesky

Entrée : matrice Σ (symétrique définie positive)
Sortie : matrice triangulaire inférieure A

Pour j = 1 à d :
    Pour i = j à d :
        v = Σ[i,j]
        Pour k = 1 à j-1 :
            v = v - A[i,k]*A[j,k]
        A[i,j] = v / (v_jj)
Retourner A

permet de simuler un vect normal


mouvement brownien geometrique

X(t+Δt) = X(t) * exp( (μ - 12σ2)Δt + σΔt * Z )


pricing call européen

Entrées : S0, K, r, σ, T, N
Pour i = 1 à N :
    Z ~ N(0,1)
    ST = S0 * exp( (r - 12σ2)T + σT Z )
    Payoff_i = max(ST - K, 0)
Fin
Prix = e^(-rT) * Moyenne(Payoff)


shéma d'euler

Pour i = 0 à n-1 :
    X_{i+1} = X_i + μ(X_i)Δt + σ(X_i)√Δt * Z_i


shéma de millstein

Pour i = 0 à n-1 :
    X_{i+1} = X_i + μ(X_i)Δt + σ(X_i)√Δt * Z_i
               + 1⁄2 σ(X_i)σ'(X_i)[(Z_i2 - 1)Δt]


methode des variables
antithétiques

Pour i = 1 à N/2 :
    U = rand()
    X1 = F1(U)
    X2 = F1(1 - U)
    Moyenne = (h(X1) + h(X2))/2
Fin

réduit la variance

methode des variables de controle

Connaître une variable g(X) dont E[g(X)] est connu.
Simuler h(X) et g(X)
b* = Cov(h,g) / Var(g)
Y = h(X) - b*(g(X) - E[g(X)])
Estimateur = Moyenne(Y)


intervalle de confiance

Marge = z * (σ / N)
IC = [moyenne - marge , moyenne + marge]




















During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.