{"id":861,"date":"2023-07-28T12:33:00","date_gmt":"2023-07-28T12:33:00","guid":{"rendered":"https:\/\/statorials.org\/it\/f-prova-python\/"},"modified":"2023-07-28T12:33:00","modified_gmt":"2023-07-28T12:33:00","slug":"f-prova-python","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/f-prova-python\/","title":{"rendered":"Come eseguire un test f in python"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Un <strong>test F<\/strong> viene utilizzato per verificare se le varianze di due popolazioni sono uguali. Le ipotesi nulla e alternativa del test sono le seguenti:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>H <sub>0<\/sub> :<\/strong> \u03c3 <sub>1<\/sub> <sup>2<\/sup> = \u03c3 <sub>2<\/sub> <sup>2<\/sup> (le varianze della popolazione sono uguali)<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>H <sub>1<\/sub> :<\/strong> \u03c3 <sub>1<\/sub> <sup>2<\/sup> \u2260 \u03c3 <sub>2<\/sub> <sup>2<\/sup> (le varianze della popolazione <em>non<\/em> sono uguali)<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo tutorial spiega come eseguire un test F in Python.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio: F-Test in Python<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Supponiamo di avere i seguenti due esempi:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>x = [18, 19, 22, 25, 27, 28, 41, 45, 51, 55]<\/strong>\n<strong>y = [14, 15, 15, 17, 18, 22, 25, 25, 27, 34]<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Possiamo utilizzare la seguente funzione per eseguire un test F per determinare se le due popolazioni da cui provengono questi campioni hanno varianze uguali:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> numpy <span style=\"color: #107d3f;\">as<\/span> np\n\n<span style=\"color: #008080;\">#define F-test function<\/span>\n<span style=\"color: #008000;\">def<\/span> f_test(x, y):\n    x = np.array(x)\n    y = np.array(y)\n    f = np.var(x, ddof=1)\/np.var(y, ddof=1) <span style=\"color: #008080;\">#calculate F test statistic<\/span>\n    dfn = x.size-1 <span style=\"color: #008080;\">#define degrees of freedom numerator<\/span>\n    dfd = y.size-1 <span style=\"color: #008080;\">#define degrees of freedom denominator<\/span>\n    p = 1-scipy.stats.f.cdf(f, dfn, dfd) <span style=\"color: #008080;\">#find p-value of F test statistic<\/span>\n    <span style=\"color: #008000;\">return<\/span> f,p\n\n<span style=\"color: #008080;\">#perform F-test\n<\/span>f_test(x, y)\n\n(4.38712, 0.019127)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">La statistica del test F \u00e8 <strong>4,38712<\/strong> e il valore p corrispondente \u00e8 <strong>0,019127<\/strong> . Poich\u00e9 questo valore p \u00e8 inferiore a 0,05, rifiuteremo l&#8217;ipotesi nulla. Ci\u00f2 significa che abbiamo prove sufficienti per affermare che le due varianze della popolazione <em>non<\/em> sono uguali.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Commenti<\/strong><\/span><\/h3>\n<ul>\n<li> <span style=\"color: #000000;\">La statistica del test F \u00e8 calcolata come s <sub>1<\/sub> <sup>2<\/sup> \/ s <sub>2<\/sub> <sup>2<\/sup> . Per impostazione predefinita, <a href=\"https:\/\/numpy.org\/doc\/stable\/reference\/generated\/numpy.var.html#:~:text=Compute%20the%20variance%20along%20the,the%20spread%20of%20a%20distribution.\" target=\"_blank\" rel=\"noopener noreferrer\">numpy.var<\/a> calcola la varianza della popolazione. Per calcolare la varianza del campione, dobbiamo specificare <strong>ddof=1<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">Il valore p corrisponde a 1 \u2013 cdf della distribuzione F con gradi di libert\u00e0 al numeratore = n <sub>1<\/sub> -1 e gradi di libert\u00e0 al denominatore = n <sub>2<\/sub> -1.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Questa funzione funziona solo quando la varianza del primo campione \u00e8 maggiore della varianza del secondo campione. Quindi imposta entrambi gli esempi per lavorare con la funzione.<\/span><\/li>\n<\/ul>\n<h3> <span style=\"color: #000000;\"><strong>Quando utilizzare il test F<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il test F viene generalmente utilizzato per rispondere a una delle seguenti domande:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>1.<\/strong> Due campioni provengono da popolazioni con varianza uguale?<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>2.<\/strong> Un nuovo trattamento o processo riduce la variabilit\u00e0 di un trattamento o processo attuale?<\/span><\/p>\n<p> <span style=\"color: #000000;\"><b>Correlato:<\/b> <a href=\"https:\/\/statorials.org\/it\/f-prova-in-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">Come eseguire un test F in R<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Un test F viene utilizzato per verificare se le varianze di due popolazioni sono uguali. Le ipotesi nulla e alternativa del test sono le seguenti: H 0 : \u03c3 1 2 = \u03c3 2 2 (le varianze della popolazione sono uguali) H 1 : \u03c3 1 2 \u2260 \u03c3 2 2 (le varianze della popolazione [&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 F in Python - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come eseguire un test F per varianze uguali in Python.\" \/>\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\/f-prova-python\/\" \/>\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 F in Python - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come eseguire un test F per varianze uguali in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/f-prova-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-28T12:33:00+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\/f-prova-python\/\",\"url\":\"https:\/\/statorials.org\/it\/f-prova-python\/\",\"name\":\"Come eseguire un test F in Python - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-28T12:33:00+00:00\",\"dateModified\":\"2023-07-28T12:33:00+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come eseguire un test F per varianze uguali in Python.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/f-prova-python\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/f-prova-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/f-prova-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come eseguire un test f 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 F in Python - Statorials","description":"Questo tutorial spiega come eseguire un test F per varianze uguali in Python.","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\/f-prova-python\/","og_locale":"it_IT","og_type":"article","og_title":"Come eseguire un test F in Python - Statorials","og_description":"Questo tutorial spiega come eseguire un test F per varianze uguali in Python.","og_url":"https:\/\/statorials.org\/it\/f-prova-python\/","og_site_name":"Statorials","article_published_time":"2023-07-28T12:33:00+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\/f-prova-python\/","url":"https:\/\/statorials.org\/it\/f-prova-python\/","name":"Come eseguire un test F in Python - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-28T12:33:00+00:00","dateModified":"2023-07-28T12:33:00+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come eseguire un test F per varianze uguali in Python.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/f-prova-python\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/f-prova-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/f-prova-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come eseguire un test f 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\/861"}],"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=861"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/861\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}