La méthode MCMC : Markoc Chain Monte Carlo (cours)

  Рет қаралды 3,920

Gilles Maurin

Gilles Maurin

Күн бұрын

Пікірлер: 2
@menadhara1352
@menadhara1352 Жыл бұрын
bonjours, question: comment utiliser q pour généré x ? merci pour votre réponse.
@Achillionable
@Achillionable Жыл бұрын
Un moyen est en fait d'utiliser une sorte de Monte-Carlo pour ça. C'est brute force, mais ça marche Un petit code python pour illustrer : import numpy as np import matplotlib.pyplot as plt X=np.linspace(0,5,1000) def Y(X): ## ma distribution q pour obtenir x return(np.sin(X*np.pi/5)*np.abs(np.sin(1/3*X**2))) from scipy.integrate import quad I=quad(Y,0,5,args=(X)) ## j'en fait l'intégrale pour être sûr d'avoir une pdf avec intégrale=1 def Y(X): ## ma distribution q pour obtenir x, intégrale=1 return(np.sin(X*np.pi/5)/I*np.abs(np.sin(1/3*X**2))) L=[] for _ in range(10000000): x=np.random.rand()*5 if Y(x)>np.random.rand(): ## L'acceptation, pour avoir le nouveau x à partir de q L+=[x] H=np.histogram(L,bins=50) plt.hist(L,bins=50) plt.plot(X,Y(X)/np.max(Y(X))*np.max(H[0])) ## Je vérifie que mes tirages suivent en effet la distribution q. Et on observe que ça marche bien en effet. Du coup, à partir d'un q classique (chez moi Y), il suffit de faire ce petit tirage. ça fonctionnera forcément car la distribution q (ici Y) est une pdf, donc elle ne peut être supérieure à 1. Le plus efficace serait de vérifier que Y(x)> a ϵ [0,max(Y)], pour éviter les tirages inutiles. maxi=np.max(Y(X)) x=np.random.rand()*5 if Y(x)>np.random.rand()*maxi Et le prochain x' sera l'x qui respecte la condition if. Il y a probablement plus simple, mais ça fonctionne, j'ai directement pensé à ça.
Tests statistiques - généralités  (cours)
17:39
Gilles Maurin
Рет қаралды 998
Metropolis - Hastings : Data Science Concepts
18:15
ritvikmath
Рет қаралды 100 М.
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 12 МЛН
Bend The Impossible Bar Win $1,000
00:57
Stokes Twins
Рет қаралды 42 МЛН
At the end of the video, deadpool did this #harleyquinn #deadpool3 #wolverin #shorts
00:15
Anastasyia Prichinina. Actress. Cosplayer.
Рет қаралды 16 МЛН
Electric Flying Bird with Hanging Wire Automatic for Ceiling Parrot
00:15
Importance Sampling
12:46
Mutual Information
Рет қаралды 60 М.
Metropolis-Hastings - VISUALLY EXPLAINED!
24:45
Kapil Sachdeva
Рет қаралды 33 М.
Monte Carlo Simulation
10:06
MarbleScience
Рет қаралды 1,4 МЛН
Markov Chains Clearly Explained! Part - 1
9:24
Normalized Nerd
Рет қаралды 1,2 МЛН
Think Fast, Talk Smart: Communication Techniques
58:20
Stanford Graduate School of Business
Рет қаралды 40 МЛН
Sampling from Bayes' Nets
25:08
Pieter Abbeel
Рет қаралды 49 М.
What is Monte Carlo Simulation?
4:35
IBM Technology
Рет қаралды 259 М.
Comment déchiffrer (presque) n'importe quel message codé ?  🔑🔓📜
13:25
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 12 МЛН