{"id":1411,"date":"2023-06-22T02:22:54","date_gmt":"2023-06-22T02:22:54","guid":{"rendered":"https:\/\/content.one.lumenlearning.com\/introstatstest\/chapter\/chi-square-test-for-goodness-of-fit-fresh-take\/"},"modified":"2025-05-16T23:40:43","modified_gmt":"2025-05-16T23:40:43","slug":"chi-square-test-for-goodness-of-fit-fresh-take","status":"publish","type":"chapter","link":"https:\/\/content.one.lumenlearning.com\/introstatstest\/chapter\/chi-square-test-for-goodness-of-fit-fresh-take\/","title":{"raw":"Chi-Square Test for Goodness of Fit \u2013 Fresh Take","rendered":"Chi-Square Test for Goodness of Fit \u2013 Fresh Take"},"content":{"raw":"<section class=\"textbox learningGoals\">\r\n<ul>\r\n\t<li><span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Complete a chi-square test for goodness of fit and write its conclusion in context of the problem&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:12801,&quot;3&quot;:{&quot;1&quot;:0},&quot;12&quot;:0,&quot;15&quot;:&quot;arial&quot;,&quot;16&quot;:9}\">Complete a chi-square test for goodness of fit and write its conclusion in context of the problem<\/span><\/li>\r\n<\/ul>\r\n<\/section>\r\n<section class=\"textbox example\"><strong><strong>Distribution of Color in Plain M&amp;M Candies<\/strong><\/strong>\r\n<p><span style=\"font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">According to the manufacturer of M&amp;M candy, the color distribution for plain chocolate M&amp;Ms is 13% brown, 13% red, 14% yellow, 24% blue, 20% orange, and 16% green.<\/span><\/p>\r\n<p>This statement about the distribution of color in plain M&amp;Ms is the null hypothesis. The alternative hypothesis says that this is not the distribution.<\/p>\r\n<ul>\r\n\t<li>[latex]H_0[\/latex]: The color distribution for plain M&amp;Ms is 13% brown, 13% red, 14% yellow, 24% blue, 20% orange, 16% green.<\/li>\r\n\t<li>[latex]H_A[\/latex]: The color distribution for plain M&amp;Ms is different from the distribution stated in the null hypothesis.<\/li>\r\n<\/ul>\r\n<p>We select a random sample of 300 plain M&amp;M candies to test these hypotheses. If the sample has the distribution of color stated in the null hypothesis, then we expect 13% of the 300 to be brown, 13% of 300 to be red, 14% of 300 to be yellow, 24% of 300 to be blue, and so on. Here are the expected counts of each color for a sample of 300 candies:<\/p>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<th>Color<\/th>\r\n<th>Brown<\/th>\r\n<th>Red<\/th>\r\n<th>Yellow<\/th>\r\n<th>Blue<\/th>\r\n<th>Orange<\/th>\r\n<th>Green<\/th>\r\n<\/tr>\r\n<tr>\r\n<th>Expected<\/th>\r\n<td>0.13(300)=39<\/td>\r\n<td>0.13(300)=39<\/td>\r\n<td>0.14(300)=42<\/td>\r\n<td>0.24(300)=72<\/td>\r\n<td>0.20(300)=60<\/td>\r\n<td>0.16(300)=48<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<p>Of course, the distribution of color will vary in different samples, so we need to develop a way to measure how far a sample distribution is from the null distribution, something analogous to a\u00a0<em>z<\/em>-score or T-score. Before we discuss this new measure, let\u2019s look at two random samples selected from the null distribution to practice recognizing different amounts of variability. We can compare the distributions visually using ribbon charts.<\/p>\r\n<div class=\"wp-nocaption alignnone\"><img class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1729\/2017\/04\/15032746\/m11_chi_square_tests_topic_11_1_m11_goodness_fit_1_image4.png\" alt=\"Ribbon charts comparing two samples of M&amp;Ms and how their color distribution compares to the null distribution.\" width=\"366\" height=\"231\" \/><\/div>\r\n<p>Which random sample deviates the most from the null distribution? Use the [latex]\\chi^2[\/latex] Test of Goodness of Fit to find the answer.<\/p>\r\n<\/section>\r\n<p><iframe src=\"https:\/\/lumen-learning.shinyapps.io\/chisquaredtest\/\" width=\"100%\" height=\"1100\" frameborder=\"no\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><br \/>\r\n[<a href=\"https:\/\/lumen-learning.shinyapps.io\/chisquaredtest\/\" target=\"_blank\" rel=\"noopener\">Trouble viewing? Click to open in a new tab.<\/a>]<\/p>\r\n<section class=\"textbox example\">Using the statistical tool:\r\n\r\n<ul>\r\n\t<li>For Sample 1, the chi-square test statistic is [latex]12.94[\/latex] with a P-value of [latex]0.0240[\/latex].<br \/>\r\n[reveal-answer q=\"907593\"]Statistical Output[\/reveal-answer]<br \/>\r\n[hidden-answer a=\"907593\"]<img class=\"aligncenter size-full wp-image-1852\" src=\"https:\/\/content-cdn.one.lumenlearning.com\/wp-content\/uploads\/sites\/27\/2023\/06\/22022252\/Screenshot-2023-02-06-at-12.45.09-PM.png\" alt=\"\" width=\"512\" height=\"677\" \/>[\/hidden-answer]<\/li>\r\n\t<li>For Sample 2, the chi-square test statistic is [latex]1.53[\/latex] with a P-value of [latex]0.9094[\/latex]<br \/>\r\n[reveal-answer q=\"226092\"]Statistical Output[\/reveal-answer]<br \/>\r\n[hidden-answer a=\"226092\"]<img class=\"aligncenter size-full wp-image-1853\" src=\"https:\/\/content-cdn.one.lumenlearning.com\/wp-content\/uploads\/sites\/27\/2023\/06\/22022253\/Screenshot-2023-02-06-at-12.45.52-PM.png\" alt=\"\" width=\"505\" height=\"677\" \/>[\/hidden-answer]<\/li>\r\n<\/ul>\r\n<p>The chi-square goodness-of-fit test does not give information about the deviation for specific categories. It gives a more general conclusion of \u201cseems to fit the null distribution\u201d or \u201cdoes not fit the null distribution.\u201d<\/p>\r\n<p>Based on the P-value on Sample 1, we have strong evidence that the color distribution for plain M&amp;M's differs from what is stated in the null hypothesis.<\/p>\r\n<p>Based on the P-value on Sample 2, we do not have enough evidence to reject the claim that the color distribution for plain M&amp;Ms differs from what is stated in the null hypothesis.<\/p>\r\n<p>Therefore, the answer to the question: \"Which random sample deviates the most from the null distribution?\" is Sample # 1.<\/p>\r\n<\/section>","rendered":"<section class=\"textbox learningGoals\">\n<ul>\n<li><span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Complete a chi-square test for goodness of fit and write its conclusion in context of the problem&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:12801,&quot;3&quot;:{&quot;1&quot;:0},&quot;12&quot;:0,&quot;15&quot;:&quot;arial&quot;,&quot;16&quot;:9}\">Complete a chi-square test for goodness of fit and write its conclusion in context of the problem<\/span><\/li>\n<\/ul>\n<\/section>\n<section class=\"textbox example\"><strong><strong>Distribution of Color in Plain M&amp;M Candies<\/strong><\/strong><\/p>\n<p><span style=\"font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">According to the manufacturer of M&amp;M candy, the color distribution for plain chocolate M&amp;Ms is 13% brown, 13% red, 14% yellow, 24% blue, 20% orange, and 16% green.<\/span><\/p>\n<p>This statement about the distribution of color in plain M&amp;Ms is the null hypothesis. The alternative hypothesis says that this is not the distribution.<\/p>\n<ul>\n<li>[latex]H_0[\/latex]: The color distribution for plain M&amp;Ms is 13% brown, 13% red, 14% yellow, 24% blue, 20% orange, 16% green.<\/li>\n<li>[latex]H_A[\/latex]: The color distribution for plain M&amp;Ms is different from the distribution stated in the null hypothesis.<\/li>\n<\/ul>\n<p>We select a random sample of 300 plain M&amp;M candies to test these hypotheses. If the sample has the distribution of color stated in the null hypothesis, then we expect 13% of the 300 to be brown, 13% of 300 to be red, 14% of 300 to be yellow, 24% of 300 to be blue, and so on. Here are the expected counts of each color for a sample of 300 candies:<\/p>\n<table>\n<tbody>\n<tr>\n<th>Color<\/th>\n<th>Brown<\/th>\n<th>Red<\/th>\n<th>Yellow<\/th>\n<th>Blue<\/th>\n<th>Orange<\/th>\n<th>Green<\/th>\n<\/tr>\n<tr>\n<th>Expected<\/th>\n<td>0.13(300)=39<\/td>\n<td>0.13(300)=39<\/td>\n<td>0.14(300)=42<\/td>\n<td>0.24(300)=72<\/td>\n<td>0.20(300)=60<\/td>\n<td>0.16(300)=48<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Of course, the distribution of color will vary in different samples, so we need to develop a way to measure how far a sample distribution is from the null distribution, something analogous to a\u00a0<em>z<\/em>-score or T-score. Before we discuss this new measure, let\u2019s look at two random samples selected from the null distribution to practice recognizing different amounts of variability. We can compare the distributions visually using ribbon charts.<\/p>\n<div class=\"wp-nocaption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1729\/2017\/04\/15032746\/m11_chi_square_tests_topic_11_1_m11_goodness_fit_1_image4.png\" alt=\"Ribbon charts comparing two samples of M&amp;Ms and how their color distribution compares to the null distribution.\" width=\"366\" height=\"231\" \/><\/div>\n<p>Which random sample deviates the most from the null distribution? Use the [latex]\\chi^2[\/latex] Test of Goodness of Fit to find the answer.<\/p>\n<\/section>\n<p><iframe loading=\"lazy\" src=\"https:\/\/lumen-learning.shinyapps.io\/chisquaredtest\/\" width=\"100%\" height=\"1100\" frameborder=\"no\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><br \/>\n[<a href=\"https:\/\/lumen-learning.shinyapps.io\/chisquaredtest\/\" target=\"_blank\" rel=\"noopener\">Trouble viewing? Click to open in a new tab.<\/a>]<\/p>\n<section class=\"textbox example\">Using the statistical tool:<\/p>\n<ul>\n<li>For Sample 1, the chi-square test statistic is [latex]12.94[\/latex] with a P-value of [latex]0.0240[\/latex].\n<div class=\"qa-wrapper\" style=\"display: block\"><button class=\"show-answer show-answer-button collapsed\" data-target=\"q907593\">Statistical Output<\/button><\/p>\n<div id=\"q907593\" class=\"hidden-answer\" style=\"display: none\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1852\" src=\"https:\/\/content-cdn.one.lumenlearning.com\/wp-content\/uploads\/sites\/27\/2023\/06\/22022252\/Screenshot-2023-02-06-at-12.45.09-PM.png\" alt=\"\" width=\"512\" height=\"677\" \/><\/div>\n<\/div>\n<\/li>\n<li>For Sample 2, the chi-square test statistic is [latex]1.53[\/latex] with a P-value of [latex]0.9094[\/latex]\n<div class=\"qa-wrapper\" style=\"display: block\"><button class=\"show-answer show-answer-button collapsed\" data-target=\"q226092\">Statistical Output<\/button><\/p>\n<div id=\"q226092\" class=\"hidden-answer\" style=\"display: none\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1853\" src=\"https:\/\/content-cdn.one.lumenlearning.com\/wp-content\/uploads\/sites\/27\/2023\/06\/22022253\/Screenshot-2023-02-06-at-12.45.52-PM.png\" alt=\"\" width=\"505\" height=\"677\" \/><\/div>\n<\/div>\n<\/li>\n<\/ul>\n<p>The chi-square goodness-of-fit test does not give information about the deviation for specific categories. It gives a more general conclusion of \u201cseems to fit the null distribution\u201d or \u201cdoes not fit the null distribution.\u201d<\/p>\n<p>Based on the P-value on Sample 1, we have strong evidence that the color distribution for plain M&amp;M&#8217;s differs from what is stated in the null hypothesis.<\/p>\n<p>Based on the P-value on Sample 2, we do not have enough evidence to reject the claim that the color distribution for plain M&amp;Ms differs from what is stated in the null hypothesis.<\/p>\n<p>Therefore, the answer to the question: &#8220;Which random sample deviates the most from the null distribution?&#8221; is Sample # 1.<\/p>\n<\/section>\n","protected":false},"author":8,"menu_order":18,"template":"","meta":{"_candela_citation":"[]","pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"part":1388,"module-header":"fresh_take","content_attributions":[],"internal_book_links":[],"video_content":null,"cc_video_embed_content":{"cc_scripts":"","media_targets":[]},"try_it_collection":null,"_links":{"self":[{"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/pressbooks\/v2\/chapters\/1411"}],"collection":[{"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/wp\/v2\/users\/8"}],"version-history":[{"count":4,"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/pressbooks\/v2\/chapters\/1411\/revisions"}],"predecessor-version":[{"id":6872,"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/pressbooks\/v2\/chapters\/1411\/revisions\/6872"}],"part":[{"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/pressbooks\/v2\/parts\/1388"}],"metadata":[{"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/pressbooks\/v2\/chapters\/1411\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/wp\/v2\/media?parent=1411"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/pressbooks\/v2\/chapter-type?post=1411"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/wp\/v2\/contributor?post=1411"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/content.one.lumenlearning.com\/introstatstest\/wp-json\/wp\/v2\/license?post=1411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}