{"id":1599,"date":"2023-07-25T17:15:30","date_gmt":"2023-07-25T17:15:30","guid":{"rendered":"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/"},"modified":"2023-07-25T17:15:30","modified_gmt":"2023-07-25T17:15:30","slug":"traccia-la-distribuzione-normale-di-python","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/","title":{"rendered":"Come tracciare una distribuzione normale in python: con esempi"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Per tracciare una <a href=\"https:\/\/statorials.org\/it\/la-distribuzione-normale\/\" target=\"_blank\" rel=\"noopener\">distribuzione normale<\/a> in Python, puoi utilizzare la seguente sintassi:<\/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;\">L&#8217;array <strong>x<\/strong> definisce l&#8217;intervallo dell&#8217;asse x e <strong>plt.plot()<\/strong> produce la curva della distribuzione normale con la media e la deviazione standard specificate.<\/span><\/p>\n<p> <span style=\"color: #000000;\">I seguenti esempi mostrano come utilizzare queste funzioni nella pratica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 1: tracciare una distribuzione normale singola<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come tracciare una singola curva di distribuzione normale con una media pari a 0 e una deviazione standard pari a 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=\"Distribuzione normale in Python\" width=\"388\" height=\"259\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Puoi anche modificare il colore e la larghezza della linea nel grafico:<\/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=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 2: tracciare pi\u00f9 distribuzioni normali<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come tracciare pi\u00f9 curve di distribuzione normale con medie e deviazioni standard diverse:<\/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=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Sentiti libero di cambiare i colori delle linee e aggiungere un titolo e le etichette degli assi per completare il grafico:<\/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=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Fare riferimento alla <a href=\"https:\/\/matplotlib.org\/stable\/api\/_as_gen\/matplotlib.pyplot.plot.html\" target=\"_blank\" rel=\"noopener\">documentazione matplotlib<\/a> per una spiegazione dettagliata della funzione <strong>plt.plot()<\/strong> .<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Per tracciare una distribuzione normale in Python, puoi utilizzare la seguente sintassi: #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)) L&#8217;array x definisce l&#8217;intervallo dell&#8217;asse x e plt.plot() produce [&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":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Come tracciare una distribuzione normale in Python: con esempi<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come tracciare una distribuzione normale in Python, con diversi esempi.\" \/>\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\/it\/traccia-la-distribuzione-normale-di-python\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come tracciare una distribuzione normale in Python: con esempi\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come tracciare una distribuzione normale in Python, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-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=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/\",\"url\":\"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/\",\"name\":\"Come tracciare una distribuzione normale in Python: con esempi\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-25T17:15:30+00:00\",\"dateModified\":\"2023-07-25T17:15:30+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come tracciare una distribuzione normale in Python, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come tracciare una distribuzione normale in python: con esempi\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come tracciare una distribuzione normale in Python: con esempi","description":"Questo tutorial spiega come tracciare una distribuzione normale in Python, con diversi esempi.","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\/it\/traccia-la-distribuzione-normale-di-python\/","og_locale":"it_IT","og_type":"article","og_title":"Come tracciare una distribuzione normale in Python: con esempi","og_description":"Questo tutorial spiega come tracciare una distribuzione normale in Python, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-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":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"2 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/","url":"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/","name":"Come tracciare una distribuzione normale in Python: con esempi","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-25T17:15:30+00:00","dateModified":"2023-07-25T17:15:30+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come tracciare una distribuzione normale in Python, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/traccia-la-distribuzione-normale-di-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come tracciare una distribuzione normale in python: con esempi"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1599"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=1599"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1599\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}