{"id":986,"date":"2023-07-28T02:22:40","date_gmt":"2023-07-28T02:22:40","guid":{"rendered":"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/"},"modified":"2023-07-28T02:22:40","modified_gmt":"2023-07-28T02:22:40","slug":"pitone-di-prova-shapiro-wilk","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/","title":{"rendered":"Come eseguire un test di shapiro-wilk in python"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Il <strong>test di Shapiro-Wilk<\/strong> \u00e8 un test di normalit\u00e0. Viene utilizzato per determinare se un campione proviene o meno da una <a href=\"https:\/\/statorials.org\/it\/la-distribuzione-normale\/\" target=\"_blank\" rel=\"noopener noreferrer\">distribuzione normale<\/a> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Per eseguire un test Shapiro-Wilk in Python possiamo utilizzare la funzione <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.stats.shapiro.html\" target=\"_blank\" rel=\"noopener noreferrer\">scipy.stats.shapiro()<\/a> , che utilizza la seguente sintassi:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>scipy.stats.shapiro(x)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Oro:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>x:<\/strong> una tabella di dati campione.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Questa funzione restituisce una statistica di test e un valore p corrispondente.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Se il valore p \u00e8 inferiore a un certo livello di significativit\u00e0, allora abbiamo prove sufficienti per affermare che i dati del campione non provengono da una distribuzione normale.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo tutorial mostra alcuni esempi di come utilizzare questa funzionalit\u00e0 nella pratica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 1: test di Shapiro-Wilk su dati distribuiti normalmente<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Supponiamo di avere i seguenti dati di esempio:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">from<\/span> numpy.random <span style=\"color: #008000;\">import<\/span> seed\n<span style=\"color: #008000;\">from<\/span> numpy.random <span style=\"color: #008000;\">import<\/span> randn\n\n<span style=\"color: #008080;\">#set seed (eg make this example reproducible)<\/span>\nseed(0)\n\n<span style=\"color: #008080;\">#generate dataset of 100 random values that follow a standard normal distribution\n<\/span>data = randn(100)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come eseguire un test Shapiro-Wilk su questo campione di 100 valori di dati per determinare se provengono da una distribuzione normale:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">from<\/span> scipy.stats <span style=\"color: #008000;\">import<\/span> shapiro\n\n<span style=\"color: #008080;\">#perform Shapiro-Wilk test<\/span>\nshapiro(data)\n\nShapiroResult(statistic=0.9926937818527222, pvalue=0.8689165711402893)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Dal risultato, possiamo vedere che la statistica del test \u00e8 <strong>0,9927<\/strong> e il corrispondente valore p \u00e8 <strong>0,8689<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Poich\u00e9 il valore p non \u00e8 inferiore a 0,05, non riusciamo a rifiutare l&#8217;ipotesi nulla. Non abbiamo prove sufficienti per affermare che i dati del campione non provengano da una distribuzione normale.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo risultato non dovrebbe sorprendere poich\u00e9 abbiamo generato i dati di esempio utilizzando la funzione <strong>randn()<\/strong> , che genera valori casuali che seguono una distribuzione normale standard.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 2: test di Shapiro-Wilk su dati distribuiti in modo non normale<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Supponiamo ora di avere i seguenti dati di esempio:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">from<\/span> numpy.random <span style=\"color: #008000;\">import<\/span> seed\n<span style=\"color: #008000;\">from<\/span> numpy.random <span style=\"color: #008000;\">import<\/span> fish\n\n<span style=\"color: #008080;\">#set seed (eg make this example reproducible)<\/span>\nseed(0)\n\n<span style=\"color: #008080;\">#generate dataset of 100 values that follows a Poisson distribution with mean=5\n<\/span>data = fish(5, 100)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come eseguire un test Shapiro-Wilk su questo campione di 100 valori di dati per determinare se provengono da una distribuzione normale:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">from<\/span> scipy.stats <span style=\"color: #008000;\">import<\/span> shapiro\n\n<span style=\"color: #008080;\">#perform Shapiro-Wilk test<\/span>\nshapiro(data)\n\nShapiroResult(statistic=0.9581913948059082, pvalue=0.002994443289935589)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Dal risultato, possiamo vedere che la statistica del test \u00e8 <strong>0,9582<\/strong> e il corrispondente valore p \u00e8 <strong>0,00299<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Poich\u00e9 il valore p \u00e8 inferiore a 0,05, rifiutiamo l&#8217;ipotesi nulla. Abbiamo prove sufficienti per affermare che i dati del campione non provengono da una distribuzione normale.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Anche questo risultato non dovrebbe sorprendere poich\u00e9 abbiamo generato i dati di esempio utilizzando la funzione <strong>Poisson()<\/strong> , che genera valori casuali che seguono una <a href=\"https:\/\/statorials.org\/it\/distribuzione-del-pesce\/\" target=\"_blank\" rel=\"noopener noreferrer\">distribuzione di Poisson<\/a> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come eseguire altri test di normalit\u00e0 in vari software statistici:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/test-shapiro-wilk-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">Come eseguire un test di Shapiro-Wilk in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/anderson-cheri-prova-pitone\/\" target=\"_blank\" rel=\"noopener noreferrer\">Come eseguire un test di Anderson-Darling in Python<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/kolmogorov-smirnov-prova-pitone\/\">Come eseguire un test di Kolmogorov-Smirnov in Python<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Il test di Shapiro-Wilk \u00e8 un test di normalit\u00e0. Viene utilizzato per determinare se un campione proviene o meno da una distribuzione normale . Per eseguire un test Shapiro-Wilk in Python possiamo utilizzare la funzione scipy.stats.shapiro() , che utilizza la seguente sintassi: scipy.stats.shapiro(x) Oro: x: una tabella di dati campione. Questa funzione restituisce una statistica [&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 eseguire un test di Shapiro-Wilk in Python - Statorials<\/title>\n<meta name=\"description\" content=\"Una semplice spiegazione di come eseguire un test di Shapiro-Wilk per la normalit\u00e0 in Python, incluso un esempio.\" \/>\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\/pitone-di-prova-shapiro-wilk\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come eseguire un test di Shapiro-Wilk in Python - Statorials\" \/>\n<meta property=\"og:description\" content=\"Una semplice spiegazione di come eseguire un test di Shapiro-Wilk per la normalit\u00e0 in Python, incluso un esempio.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-28T02:22:40+00:00\" \/>\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\/pitone-di-prova-shapiro-wilk\/\",\"url\":\"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/\",\"name\":\"Come eseguire un test di Shapiro-Wilk in Python - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-28T02:22:40+00:00\",\"dateModified\":\"2023-07-28T02:22:40+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Una semplice spiegazione di come eseguire un test di Shapiro-Wilk per la normalit\u00e0 in Python, incluso un esempio.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come eseguire un test di shapiro-wilk in python\"}]},{\"@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 eseguire un test di Shapiro-Wilk in Python - Statorials","description":"Una semplice spiegazione di come eseguire un test di Shapiro-Wilk per la normalit\u00e0 in Python, incluso un esempio.","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\/pitone-di-prova-shapiro-wilk\/","og_locale":"it_IT","og_type":"article","og_title":"Come eseguire un test di Shapiro-Wilk in Python - Statorials","og_description":"Una semplice spiegazione di come eseguire un test di Shapiro-Wilk per la normalit\u00e0 in Python, incluso un esempio.","og_url":"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/","og_site_name":"Statorials","article_published_time":"2023-07-28T02:22:40+00:00","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\/pitone-di-prova-shapiro-wilk\/","url":"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/","name":"Come eseguire un test di Shapiro-Wilk in Python - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-28T02:22:40+00:00","dateModified":"2023-07-28T02:22:40+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Una semplice spiegazione di come eseguire un test di Shapiro-Wilk per la normalit\u00e0 in Python, incluso un esempio.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/pitone-di-prova-shapiro-wilk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come eseguire un test di shapiro-wilk in python"}]},{"@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\/986"}],"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=986"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/986\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}