{"id":1598,"date":"2023-07-25T17:15:30","date_gmt":"2023-07-25T17:15:30","guid":{"rendered":"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/"},"modified":"2023-07-25T17:15:30","modified_gmt":"2023-07-25T17:15:30","slug":"tracar-distribuicao-normal-python","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/","title":{"rendered":"Como tra\u00e7ar uma distribui\u00e7\u00e3o normal em python: com exemplos"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Para tra\u00e7ar uma <a href=\"https:\/\/statorials.org\/pt\/a-distribuicao-normal\/\" target=\"_blank\" rel=\"noopener\">distribui\u00e7\u00e3o normal<\/a> em Python, voc\u00ea pode usar a seguinte sintaxe:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#x-axis ranges from -3 and 3 with .001 steps\n<\/span>x = np. <span style=\"color: #3366ff;\">arange<\/span> (-3, 3, 0.001)\n\n<span style=\"color: #008080;\">#plot normal distribution with mean 0 and standard deviation 1\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x, norm. <span style=\"color: #3366ff;\">pdf<\/span> (x, 0, 1))\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">A matriz <strong>x<\/strong> define o intervalo do eixo x e <strong>plt.plot()<\/strong> produz a curva da distribui\u00e7\u00e3o normal com a m\u00e9dia e o desvio padr\u00e3o especificados.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Os exemplos a seguir mostram como usar essas fun\u00e7\u00f5es na pr\u00e1tica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 1: tra\u00e7ando uma \u00fanica distribui\u00e7\u00e3o normal<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como tra\u00e7ar uma \u00fanica curva de distribui\u00e7\u00e3o normal com m\u00e9dia 0 e desvio padr\u00e3o de 1:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n<span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">from<\/span> scipy. <span style=\"color: #3366ff;\">stats<\/span> <span style=\"color: #008000;\">import<\/span> norm\n\n<span style=\"color: #008080;\">#x-axis ranges from -3 and 3 with .001 steps\n<\/span>x = np. <span style=\"color: #3366ff;\">arange<\/span> (-3, 3, 0.001)\n\n<span style=\"color: #008080;\">#plot normal distribution with mean 0 and standard deviation 1\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x, norm. <span style=\"color: #3366ff;\">pdf<\/span> (x, 0, 1))<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-15893\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/normaldistpython1.png\" alt=\"Distribui\u00e7\u00e3o normal em Python\" width=\"388\" height=\"259\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Voc\u00ea tamb\u00e9m pode alterar a cor e a largura da linha no gr\u00e1fico:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>plt. <span style=\"color: #3366ff;\">plot<\/span> (x, norm. <span style=\"color: #3366ff;\">pdf<\/span> (x, 0, 1), color=' <span style=\"color: #ff0000;\">red<\/span> ', linewidth= <span style=\"color: #008000;\">3<\/span> )<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-15894 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/normaldistpython2.png\" alt=\"\" width=\"403\" height=\"264\" srcset=\"\" sizes=\"auto, \"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 2: tra\u00e7ando m\u00faltiplas distribui\u00e7\u00f5es normais<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como tra\u00e7ar m\u00faltiplas curvas de distribui\u00e7\u00e3o normal com diferentes m\u00e9dias e desvios padr\u00e3o:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n<span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">from<\/span> scipy. <span style=\"color: #3366ff;\">stats<\/span> <span style=\"color: #008000;\">import<\/span> norm\n\n<span style=\"color: #008080;\">#x-axis ranges from -5 and 5 with .001 steps\n<\/span>x = np. <span style=\"color: #3366ff;\">arange<\/span> (-5, 5, 0.001)\n\n<span style=\"color: #008080;\">#define multiple normal distributions\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x, norm. <span style=\"color: #3366ff;\">pdf<\/span> (x, 0, 1), label=' <span style=\"color: #ff0000;\">\u03bc: 0, \u03c3: 1<\/span> ')\nplt. <span style=\"color: #3366ff;\">plot<\/span> (x, norm. <span style=\"color: #3366ff;\">pdf<\/span> (x, 0, 1.5), label=' <span style=\"color: #ff0000;\">\u03bc:0, \u03c3: 1.5<\/span> ')\nplt. <span style=\"color: #3366ff;\">plot<\/span> (x, norm. <span style=\"color: #3366ff;\">pdf<\/span> (x, 0, 2), label=' <span style=\"color: #ff0000;\">\u03bc:0, \u03c3: 2<\/span> ')\n\n<span style=\"color: #008080;\">#add legend to plot\n<\/span>plt. <span style=\"color: #3366ff;\">legend<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-15895 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/normaldistpython3.png\" alt=\"\" width=\"388\" height=\"259\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Sinta-se \u00e0 vontade para alterar as cores das linhas e adicionar um t\u00edtulo e r\u00f3tulos de eixo para completar o gr\u00e1fico:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n<span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">from<\/span> scipy. <span style=\"color: #3366ff;\">stats<\/span> <span style=\"color: #008000;\">import<\/span> norm\n\n<span style=\"color: #008080;\">#x-axis ranges from -5 and 5 with .001 steps\n<\/span>x = np. <span style=\"color: #3366ff;\">arange<\/span> (-5, 5, 0.001)\n\n<span style=\"color: #008080;\">#define multiple normal distributions\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x, norm. <span style=\"color: #3366ff;\">pdf<\/span> (x, 0, 1), label=' <span style=\"color: #ff0000;\">\u03bc: 0, \u03c3: 1<\/span> ', color=' <span style=\"color: #ff0000;\">gold<\/span> ')\nplt. <span style=\"color: #3366ff;\">plot<\/span> (x, norm. <span style=\"color: #3366ff;\">pdf<\/span> (x, 0, 1.5), label=' <span style=\"color: #ff0000;\">\u03bc:0, \u03c3: 1.5<\/span> ', color=' <span style=\"color: #ff0000;\">red<\/span> ')\nplt. <span style=\"color: #3366ff;\">plot<\/span> (x, norm. <span style=\"color: #3366ff;\">pdf<\/span> (x, 0, 2), label=' <span style=\"color: #ff0000;\">\u03bc:0, \u03c3: 2<\/span> ', color=' <span style=\"color: #ff0000;\">pink<\/span> ')\n\n<span style=\"color: #008080;\">#add legend to plot\n<\/span>plt. <span style=\"color: #3366ff;\">legend<\/span> (title=' <span style=\"color: #ff0000;\">Parameters<\/span> ')\n\n<span style=\"color: #008080;\">#add axes labels and a title\n<\/span>plt. <span style=\"color: #3366ff;\">ylabel<\/span> (' <span style=\"color: #ff0000;\">Density<\/span> ')\nplt. <span style=\"color: #3366ff;\">xlabel<\/span> (' <span style=\"color: #ff0000;\">x<\/span> ')\nplt. <span style=\"color: #3366ff;\">title<\/span> (' <span style=\"color: #ff0000;\">Normal Distributions<\/span> ', fontsize= <span style=\"color: #008000;\">14<\/span> )<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-15896 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/normaldistpython4.png\" alt=\"\" width=\"416\" height=\"291\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Consulte a <a href=\"https:\/\/matplotlib.org\/stable\/api\/_as_gen\/matplotlib.pyplot.plot.html\" target=\"_blank\" rel=\"noopener\">documenta\u00e7\u00e3o do matplotlib<\/a> para uma explica\u00e7\u00e3o detalhada da fun\u00e7\u00e3o <strong>plt.plot()<\/strong> .<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Para tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python, voc\u00ea pode usar a seguinte sintaxe: #x-axis ranges from -3 and 3 with .001 steps x = np. arange (-3, 3, 0.001) #plot normal distribution with mean 0 and standard deviation 1 plt. plot (x, norm. pdf (x, 0, 1)) A matriz x define o intervalo do eixo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1598","post","type-post","status-publish","format-standard","hentry","category-guia"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python: com exemplos<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python, com v\u00e1rios exemplos.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python: com exemplos\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python, com v\u00e1rios exemplos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-25T17:15:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/normaldistpython1.png\" \/>\n<meta name=\"author\" content=\"Dr. benjamim anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr. benjamim anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo estimado de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/\",\"url\":\"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/\",\"name\":\"Como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python: com exemplos\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-25T17:15:30+00:00\",\"dateModified\":\"2023-07-25T17:15:30+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python, com v\u00e1rios exemplos.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como tra\u00e7ar uma distribui\u00e7\u00e3o normal em python: com exemplos\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/pt\/#website\",\"url\":\"https:\/\/statorials.org\/pt\/\",\"name\":\"Statorials\",\"description\":\"O seu guia para a literacia estat\u00edstica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/pt\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pt-PT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\",\"name\":\"Dr. benjamim anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. benjamim anderson\"},\"description\":\"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais\",\"sameAs\":[\"https:\/\/statorials.org\/pt\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python: com exemplos","description":"Este tutorial explica como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python, com v\u00e1rios exemplos.","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:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/","og_locale":"pt_PT","og_type":"article","og_title":"Como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python: com exemplos","og_description":"Este tutorial explica como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python, com v\u00e1rios exemplos.","og_url":"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/","og_site_name":"Statorials","article_published_time":"2023-07-25T17:15:30+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/normaldistpython1.png"}],"author":"Dr. benjamim anderson","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Dr. benjamim anderson","Tempo estimado de leitura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/","url":"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/","name":"Como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python: com exemplos","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-25T17:15:30+00:00","dateModified":"2023-07-25T17:15:30+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como tra\u00e7ar uma distribui\u00e7\u00e3o normal em Python, com v\u00e1rios exemplos.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/tracar-distribuicao-normal-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como tra\u00e7ar uma distribui\u00e7\u00e3o normal em python: com exemplos"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/pt\/#website","url":"https:\/\/statorials.org\/pt\/","name":"Statorials","description":"O seu guia para a literacia estat\u00edstica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/pt\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pt-PT"},{"@type":"Person","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666","name":"Dr. benjamim anderson","image":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr. benjamim anderson"},"description":"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais","sameAs":["https:\/\/statorials.org\/pt"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/1598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/comments?post=1598"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/1598\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=1598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=1598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=1598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}