{"id":5147,"date":"2020-12-08T16:44:48","date_gmt":"2020-12-08T15:44:48","guid":{"rendered":"https:\/\/www.mathweb.fr\/euclide\/?p=5147"},"modified":"2020-12-10T00:08:54","modified_gmt":"2020-12-09T23:08:54","slug":"planche-galton-python-latex","status":"publish","type":"post","link":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/","title":{"rendered":"Planche de Galton, Python et LaTeX"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Planche de Galton, Python et LaTeX. Sur <a href=\"https:\/\/www.mathweb.fr\/euclide\/simulation-de-la-planche-de-galton-en-python\/\">cette page<\/a>, j&#8217;ai expliqu\u00e9 comment simuler l&#8217;exp\u00e9rience de la <a href=\"https:\/\/fr.wikipedia.org\/wiki\/Planche_de_Galton\" target=\"_blank\" rel=\"noreferrer noopener\">planche de Galton<\/a> \u00e0 l&#8217;aide de Python. Je souhaite dans cet article aller plus loin en obtenant un fichier PDF du r\u00e9sultat obtenu avec \\(\\LaTeX\\).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Il y a deux approches possibles: utiliser PythonTeX, ou g\u00e9n\u00e9rer le fichier \\(\\LaTeX\\) directement en Python.<\/p>\n\n\n\n<!--more-->\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 counter-hierarchy ez-toc-counter ez-toc-white ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Au menu sur cette page...<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/#Planche_de_Galton_Python_et_LaTeX_approche_avec_pythontex\" >Planche de Galton, Python et LaTeX :  approche avec pythontex<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/#Approche_avec_generation_du_code_LaTeX_en_Python\" >Approche avec g\u00e9n\u00e9ration du code \\(\\LaTeX\\) en Python<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Planche_de_Galton_Python_et_LaTeX_approche_avec_pythontex\"><\/span>Planche de Galton, Python et LaTeX :  approche avec pythontex<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">C&#8217;est l&#8217;approche la moins int\u00e9ressante. En effet, cette compilation a un inconv\u00e9nient majeur: \u00e0 chaque fois, il est n\u00e9cessaire de supprimer les fichiers auxiliaires cr\u00e9\u00e9s par la compilation pour obtenir un nouveau document. Je m&#8217;explique: je compile le document suivant via pythontex.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"latex\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\\documentclass{article}\n\\usepackage{tikz}\n\\usepackage{pythontex}\n\\usepackage[margin=5mm]{geometry}\n\n\\begin{document}\n\n\\begin{center}\n\\begin{pycode}\nfrom random import choice\n\ndef simulation_galton(c = 7 , n = 20):\n    base = c * [0]\n    for bille in range(n):\n        position = c \/\/ 2\n        for clou in range(c-1):\n            position += choice([-1,1])\/2\n            \n        base[ int(position) ] += 1\n\n    return base\n\ndef graph_latex( L ):\n    ligne = '\\\\begin{tikzpicture}\\n'\n    for i in range(len(L)): # pour chaque \u00e9l\u00e9ment de L\n        if L[i] != 0: # si l'\u00e9l\u00e9ment est non nul\n            for y in range(1,L[i]): # on trace L[i] billes \u00e0 la verticale\n                ligne += '\\\\shade[ball color = blue] (' + str(i+0.5) + ' , ' + str(y) + ') circle (5mm);\\n'\n    \n    ligne += '\\\\draw[very thick] (0,0.5) -- (' + str(len(L)) + ',0.5);\\n'\n    for x in range( len(L)+1 ):\n        ligne += '\\\\draw[very thick] ('+str(x)+','+str(0.5)+') -- ('+str(x)+','+str( max(L) )+');\\n'\n    for y in range( len(L) ):\n        for x in range( y ):\n            ligne += '\\\\fill[gray] (' + str(1+3-y\/2+x) + ',' + str(max(L) + 0.5 + 1.5*(len(L)-y-1)) + ') circle (1mm);\\n'\n    ligne += '\\\\end{tikzpicture}'\n    return ligne\n    \nprint( graph_latex( simulation_galton(n=50) ) )   \n\\end{pycode}\n\n\\end{center}\n\\end{document}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">et j&#8217;obtiens le PDF suivant:<\/p>\n\n\n\n<div class=\"wp-block-file aligncenter\"><a  href=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/Galton.pdf\" data-fancybox data-type=\"iframe\" data-width=\"90%\" data-height=\"100%\" data-preload=\"false\">Galton<\/a><a  href=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/Galton.pdf\" class=\"wp-block-file__button\" download data-fancybox data-type=\"iframe\" data-width=\"90%\" data-height=\"100%\" data-preload=\"false\">T\u00e9l\u00e9charger<\/a><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Mais \u00e0 ce stade, si je ne fais rien de plus que compiler \u00e0 nouveau, j&#8217;obtiens exactement le m\u00eame document. Or, ce que je voudrais, c&#8217;est une autre simulation&#8230; Pour se faire, je suis oblig\u00e9 de supprimer le r\u00e9pertoire <em>pythontex-files-temp<\/em> cr\u00e9\u00e9 lors de la compilation via pythontex.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ce n&#8217;est pas pratique&#8230; C&#8217;est pour cela que je pr\u00e9f\u00e8re la seconde fa\u00e7on.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Approche_avec_generation_du_code_LaTeX_en_Python\"><\/span>Approche avec g\u00e9n\u00e9ration du code \\(\\LaTeX\\) en Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Cette approche est \u00e0 mon sens bien plus efficace.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On part du programme Python suivant:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from random import choice\nfrom os import system\n\ndef simulation_galton(c = 7 , n = 20):\n    base = c * [0]\n    for bille in range(n):\n        position = c \/\/ 2\n        for clou in range(c-1):\n            position += choice([-1,1])\/2\n            \n        base[ int(position) ] += 1\n\n    return base\n\ndef graph_latex( L ):\n    ligne = '\\\\documentclass{standalone}\\n'\n    ligne += '\\\\usepackage{tikz}\\n'\n    ligne += '\\\\begin{document}\\n'\n    ligne += '\\\\begin{tikzpicture}\\n'\n    for i in range(len(L)): # pour chaque \u00e9l\u00e9ment de L\n        if L[i] != 0: # si l'\u00e9l\u00e9ment est non nul\n            for y in range(1,L[i]): # on trace L[i] billes \u00e0 la verticale\n                ligne += '\\\\shade[ball color = blue] (' + str(i+0.5) + ' , ' + str(y) + ') circle (5mm);\\n'\n    \n    ligne += '\\\\draw[very thick] (0,0.5) -- (' + str(len(L)) + ',0.5);\\n'\n    for x in range( len(L)+1 ):\n        ligne += '\\\\draw[very thick] ('+str(x)+','+str(0.5)+') -- ('+str(x)+','+str( max(L) )+');\\n'\n    for y in range( len(L) ):\n        for x in range( y ):\n            ligne += '\\\\fill[gray] (' + str(1+3-y\/2+x) + ',' + str(max(L) + 0.5 + 1.5*(len(L)-y-1)) + ') circle (1mm);\\n'\n    ligne += '\\\\end{tikzpicture}\\n'\n    ligne += '\\\\end{document}'\n    return ligne\n\n\"\"\"\ncr\u00e9ation du fichier LaTeX\n\"\"\"\nlatex = graph_latex( simulation_galton(n=50) )\nfichier = open('galton.tex' , 'w', encoding = 'utf8')\nfichier.write( latex )\nfichier.close()\n\n\"\"\"\ncompilation via pdflatex\n\"\"\"\n\nsystem('pdflatex galton.tex')\nsystem('start galton.pdf')\n\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Il va d&#8217;une part simuler une exp\u00e9rience (ici, avec 7 colonnes et 50 billes), g\u00e9n\u00e9rer le fichier \\(\\LaTeX\\), le compiler et afficher le PDF, comme celui-ci par exemple:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"252\" height=\"1024\" src=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/Galton-252x1024.jpg\" alt=\"planche de galton python latex\" class=\"wp-image-5149\" srcset=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/Galton-252x1024.jpg 252w, https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/Galton-74x300.jpg 74w, https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/Galton.jpg 277w\" sizes=\"auto, (max-width: 252px) 100vw, 252px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Il est alors ais\u00e9 de modifier l\u00e9g\u00e8rement le programme Python pour g\u00e9n\u00e9rer autant d&#8217;exp\u00e9riences que souhait\u00e9.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\"\"\"\ncr\u00e9ation des fichiers LaTeX &amp; PDF\n\"\"\"\next = [ 'log' , 'tex' , 'aux' ]\nfor k in range(5):\n    latex = graph_latex( simulation_galton(n=50) )\n    fichier = open('galton-'+str(k+1)+'.tex' , 'w', encoding = 'utf8')\n    fichier.write( latex )\n    fichier.close()\n\n    \"\"\"\n    compilation via pdflatex\n    \"\"\"\n\n    system('pdflatex galton-'+str(k+1)+'.tex')\n    for e in ext:\n        system('erase galton-' + str(k+1) + '.' + e)\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Ici, j&#8217;ai opt\u00e9 pour le fait de supprimer tous les fichiers qui ne servent \u00e0 rien pour ne garder que les fichiers PDF.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u00c0 noter que je suis sous Windows 10; j&#8217;utilise donc la commande &#8220;erase&#8221;. Sous Linux et MacOS, il me semble que c&#8217;est la commande &#8220;rm &lt;fichier.ext&gt;&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">La simulation de ces exp\u00e9riences est au programme de sp\u00e9cialit\u00e9 math\u00e9matiques en Terminale. Cette derni\u00e8re approche peut donc aider les enseignant\u00b7e\u00b7s \u00e0 construire un cours avec illustrations.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Planche de Galton, Python et LaTeX. Sur cette page, j&#8217;ai expliqu\u00e9 comment simuler l&#8217;exp\u00e9rience de la planche de Galton \u00e0 l&#8217;aide de Python. Je souhaite dans cet article aller plus loin en obtenant un fichier PDF du r\u00e9sultat obtenu avec \\(\\LaTeX\\). Il y a deux approches possibles: utiliser PythonTeX, ou [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5150,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,1,6,5],"tags":[251,169,250],"class_list":["post-5147","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enseignement","category-latex","category-mathematiques","category-python","tag-loi-binomiale","tag-probabilites","tag-simulation"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Planche de Galton, Python et LaTeX - Mathweb.fr - Programmes complets<\/title>\n<meta name=\"description\" content=\"Simulation de la planche de Galton, et visualisation \u00e0 l&#039;aide de Python et LaTeX. Programmes complets suivant deux approches.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Planche de Galton, Python et LaTeX - Mathweb.fr - Programmes complets\" \/>\n<meta property=\"og:description\" content=\"Simulation de la planche de Galton, et visualisation \u00e0 l&#039;aide de Python et LaTeX. Programmes complets suivant deux approches.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/\" \/>\n<meta property=\"og:site_name\" content=\"Mathweb.fr\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-08T15:44:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-09T23:08:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/head-galton-python-latex.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"740\" \/>\n\t<meta property=\"og:image:height\" content=\"198\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"St\u00e9phane Pasquet\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"St\u00e9phane Pasquet\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/\"},\"author\":{\"name\":\"St\u00e9phane Pasquet\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#\\\/schema\\\/person\\\/e4d3bb07968238378f0d5052a70dcd69\"},\"headline\":\"Planche de Galton, Python et LaTeX\",\"datePublished\":\"2020-12-08T15:44:48+00:00\",\"dateModified\":\"2020-12-09T23:08:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/\"},\"wordCount\":363,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#\\\/schema\\\/person\\\/e4d3bb07968238378f0d5052a70dcd69\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/head-galton-python-latex.jpg\",\"keywords\":[\"loi binomiale\",\"probabilit\u00e9s\",\"simulation\"],\"articleSection\":[\"Enseignement\",\"LaTeX\",\"Math\u00e9matiques\",\"Python\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/\",\"url\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/\",\"name\":\"Planche de Galton, Python et LaTeX - Mathweb.fr - Programmes complets\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/head-galton-python-latex.jpg\",\"datePublished\":\"2020-12-08T15:44:48+00:00\",\"dateModified\":\"2020-12-09T23:08:54+00:00\",\"description\":\"Simulation de la planche de Galton, et visualisation \u00e0 l'aide de Python et LaTeX. Programmes complets suivant deux approches.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/head-galton-python-latex.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/head-galton-python-latex.jpg\",\"width\":740,\"height\":198,\"caption\":\"planche galton python latex\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2020\\\/12\\\/08\\\/planche-galton-python-latex\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Planche de Galton, Python et LaTeX\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#website\",\"url\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/\",\"name\":\"Mathweb.fr\",\"description\":\"Math\u00e9matiques, LaTeX et Python\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#\\\/schema\\\/person\\\/e4d3bb07968238378f0d5052a70dcd69\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#\\\/schema\\\/person\\\/e4d3bb07968238378f0d5052a70dcd69\",\"name\":\"St\u00e9phane Pasquet\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-logo-mathweb.webp\",\"url\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-logo-mathweb.webp\",\"contentUrl\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-logo-mathweb.webp\",\"width\":74,\"height\":77,\"caption\":\"St\u00e9phane Pasquet\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-logo-mathweb.webp\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Planche de Galton, Python et LaTeX - Mathweb.fr - Programmes complets","description":"Simulation de la planche de Galton, et visualisation \u00e0 l'aide de Python et LaTeX. Programmes complets suivant deux approches.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/","og_locale":"fr_FR","og_type":"article","og_title":"Planche de Galton, Python et LaTeX - Mathweb.fr - Programmes complets","og_description":"Simulation de la planche de Galton, et visualisation \u00e0 l'aide de Python et LaTeX. Programmes complets suivant deux approches.","og_url":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/","og_site_name":"Mathweb.fr","article_published_time":"2020-12-08T15:44:48+00:00","article_modified_time":"2020-12-09T23:08:54+00:00","og_image":[{"width":740,"height":198,"url":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/head-galton-python-latex.jpg","type":"image\/jpeg"}],"author":"St\u00e9phane Pasquet","twitter_card":"summary_large_image","twitter_misc":{"\u00c9crit par":"St\u00e9phane Pasquet","Dur\u00e9e de lecture estim\u00e9e":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/#article","isPartOf":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/"},"author":{"name":"St\u00e9phane Pasquet","@id":"https:\/\/www.mathweb.fr\/euclide\/#\/schema\/person\/e4d3bb07968238378f0d5052a70dcd69"},"headline":"Planche de Galton, Python et LaTeX","datePublished":"2020-12-08T15:44:48+00:00","dateModified":"2020-12-09T23:08:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/"},"wordCount":363,"commentCount":0,"publisher":{"@id":"https:\/\/www.mathweb.fr\/euclide\/#\/schema\/person\/e4d3bb07968238378f0d5052a70dcd69"},"image":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/head-galton-python-latex.jpg","keywords":["loi binomiale","probabilit\u00e9s","simulation"],"articleSection":["Enseignement","LaTeX","Math\u00e9matiques","Python"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/","url":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/","name":"Planche de Galton, Python et LaTeX - Mathweb.fr - Programmes complets","isPartOf":{"@id":"https:\/\/www.mathweb.fr\/euclide\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/#primaryimage"},"image":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/head-galton-python-latex.jpg","datePublished":"2020-12-08T15:44:48+00:00","dateModified":"2020-12-09T23:08:54+00:00","description":"Simulation de la planche de Galton, et visualisation \u00e0 l'aide de Python et LaTeX. Programmes complets suivant deux approches.","breadcrumb":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/#primaryimage","url":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/head-galton-python-latex.jpg","contentUrl":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2020\/12\/head-galton-python-latex.jpg","width":740,"height":198,"caption":"planche galton python latex"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mathweb.fr\/euclide\/2020\/12\/08\/planche-galton-python-latex\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.mathweb.fr\/euclide\/"},{"@type":"ListItem","position":2,"name":"Planche de Galton, Python et LaTeX"}]},{"@type":"WebSite","@id":"https:\/\/www.mathweb.fr\/euclide\/#website","url":"https:\/\/www.mathweb.fr\/euclide\/","name":"Mathweb.fr","description":"Math\u00e9matiques, LaTeX et Python","publisher":{"@id":"https:\/\/www.mathweb.fr\/euclide\/#\/schema\/person\/e4d3bb07968238378f0d5052a70dcd69"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mathweb.fr\/euclide\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":["Person","Organization"],"@id":"https:\/\/www.mathweb.fr\/euclide\/#\/schema\/person\/e4d3bb07968238378f0d5052a70dcd69","name":"St\u00e9phane Pasquet","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2025\/06\/cropped-logo-mathweb.webp","url":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2025\/06\/cropped-logo-mathweb.webp","contentUrl":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2025\/06\/cropped-logo-mathweb.webp","width":74,"height":77,"caption":"St\u00e9phane Pasquet"},"logo":{"@id":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2025\/06\/cropped-logo-mathweb.webp"}}]}},"_links":{"self":[{"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/posts\/5147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/comments?post=5147"}],"version-history":[{"count":0,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/posts\/5147\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/media\/5150"}],"wp:attachment":[{"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/media?parent=5147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/categories?post=5147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/tags?post=5147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}