{"id":1804,"date":"2024-01-09T16:42:44","date_gmt":"2024-01-09T15:42:44","guid":{"rendered":"https:\/\/blog.univ-angers.fr\/mathsinfo\/?p=1804"},"modified":"2024-01-12T17:09:20","modified_gmt":"2024-01-12T16:09:20","slug":"coccinelle-et-chaine-de-markov","status":"publish","type":"post","link":"https:\/\/blog.univ-angers.fr\/mathsinfo\/2024\/01\/09\/coccinelle-et-chaine-de-markov\/","title":{"rendered":"Coccinelle et chaine de Markov"},"content":{"rendered":"\n<p>Voici l&rsquo;\u00e9nonc\u00e9 d&rsquo;un probl\u00e8me que j&rsquo;ai post\u00e9 sur le groupe <a href=\"https:\/\/www.facebook.com\/groups\/hpcalculatorclub\/\">HP Calculator Fan Club<\/a><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-1024x576.png\" alt=\"\" class=\"wp-image-1805\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-1024x576.png 1024w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-300x169.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-768x432.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-1536x864.png 1536w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-500x281.png 500w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Des propositions de simulations pour quelques calculatrices HP :<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-4-1024x576.png\" alt=\"\" class=\"wp-image-1815\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-4-1024x576.png 1024w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-4-300x169.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-4-768x432.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-4-1536x864.png 1536w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-4-500x281.png 500w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-4.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Le calcul th\u00e9orique est tr\u00e8s simple :<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-3-1024x576.png\" alt=\"\" class=\"wp-image-1810\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-3-1024x576.png 1024w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-3-300x169.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-3-768x432.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-3-1536x864.png 1536w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-3-500x281.png 500w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/01\/image-3.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>La r\u00e9ponse \u00e0 trouver \u00e9tait donc : <strong>5 mouvements<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Version en Python<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>from random import random\n\ndef simul(n:int):\n    tot = 0    # Total de tous les mouvements\n    for _ in range(n):    # n simulations\n        r = 1       # Dernier mvt de 2 vers 1\n        # Aller-retour de 2 vers 3 ou 4 avec probabilit\u00e9 2\/3\n        while int(3 * random()) != 0: r += 2\n        # On ajoute le nb de mvt au total\n        tot += r\n    # Moyenne\n    return tot \/ n\n\n&gt;&gt;&gt; simul(1000)\n4.752\n&gt;&gt;&gt; simul(10000)\n5.0992\n&gt;&gt;&gt; simul(100000)\n4.98308<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Voici l&rsquo;\u00e9nonc\u00e9 d&rsquo;un probl\u00e8me que j&rsquo;ai post\u00e9 sur le groupe HP Calculator Fan Club Des propositions de simulations pour quelques calculatrices HP : Le calcul th\u00e9orique est tr\u00e8s simple : La r\u00e9ponse \u00e0 trouver \u00e9tait donc : 5 mouvements Version &hellip; <a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/2024\/01\/09\/coccinelle-et-chaine-de-markov\/\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4913,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1804","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/users\/4913"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/comments?post=1804"}],"version-history":[{"count":7,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1804\/revisions"}],"predecessor-version":[{"id":1817,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1804\/revisions\/1817"}],"wp:attachment":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/media?parent=1804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/categories?post=1804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/tags?post=1804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}