Lucas Kent e39465ad2f Changes to be committed:
new file:   Files/flashplayer_32_sa.exe
	new file:   favicon.ico
	new file:   globe.gif
	new file:   imgs/download.png
	new file:   imgs/zuck.jpg
	new file:   index.html
	new file:   other.ico
	new file:   script.js
	new file:   site.webmanifest
	new file:   sitemap.html
	new file:   styles/backround.css
	new file:   styles/border.css
	new file:   styles/fonts/Titillium_Web/OFL.txt
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Black.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Bold.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-BoldItalic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-ExtraLightItalic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Italic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Light.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-LightItalic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Regular.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-SemiBoldItalic.ttf
	new file:   styles/fonts/webfontkit-20221027-163353/generator_config.txt
	new file:   styles/fonts/webfontkit-20221027-163353/specimen_files/grid_12-825-55-15.css
	new file:   styles/fonts/webfontkit-20221027-163353/specimen_files/specimen_stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-163353/stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-demo.html
	new file:   styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff
	new file:   styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff2
	new file:   styles/fonts/webfontkit-20221027-165950/generator_config.txt
	new file:   styles/fonts/webfontkit-20221027-165950/specimen_files/grid_12-825-55-15.css
	new file:   styles/fonts/webfontkit-20221027-165950/specimen_files/specimen_stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-165950/stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-demo.html
	new file:   styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff
	new file:   styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff2
	new file:   styles/style.css
	new file:   tools/2048/.gitignore
	new file:   tools/2048/.jshintrc
	new file:   tools/2048/CONTRIBUTING.md
	new file:   tools/2048/LICENSE.txt
	new file:   tools/2048/README.md
	new file:   tools/2048/Rakefile
	new file:   tools/2048/favicon.ico
	new file:   tools/2048/index.html
	new file:   tools/2048/js/animframe_polyfill.js
	new file:   tools/2048/js/application.js
	new file:   tools/2048/js/bind_polyfill.js
	new file:   tools/2048/js/classlist_polyfill.js
	new file:   tools/2048/js/game_manager.js
	new file:   tools/2048/js/grid.js
	new file:   tools/2048/js/html_actuator.js
	new file:   tools/2048/js/keyboard_input_manager.js
	new file:   tools/2048/js/local_storage_manager.js
	new file:   tools/2048/js/tile.js
    new file:   tools/2048/meta/apple-touch-icon.png
	new file:   tools/webretro/cores/neocd_libretro.js
	new file:   tools/webretro/cores/neocd_libretro.wasm
	new file:   tools/webretro/cores/nestopia_libretro.js
	new file:   tools/webretro/cores/nestopia_libretro.wasm
	new file:   tools/webretro/cores/o2em_libretro.js
	new file:   tools/webretro/cores/o2em_libretro.wasm
	new file:   tools/webretro/cores/opera_libretro.js
	new file:   tools/webretro/cores/opera_libretro.wasm
2022-11-02 08:40:01 -04:00

415 lines
16 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en"><!-- #BeginTemplate "/Templates/Advanced.dwt" --><!-- DW6 -->
<!-- Mirrored from www.mathsisfun.com/data/chi-square-test.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 29 Oct 2022 00:31:54 GMT -->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!-- #BeginEditable "doctitle" -->
<title>Chi-Square Test</title>
<meta name="description" content="The Chi-Square Test gives a way to help you decide if something is just random chance or not." />
<script>reSpell=[["color","colour"]];</script>
<!-- #EndEditable -->
<meta name="keywords" content="math, maths, mathematics, school, homework, education">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="HandheldFriendly" content="true">
<meta name="referrer" content="always">
<link rel="stylesheet" type="text/css" href="../style3.css">
<script src="../main3.js"></script>
</head>
<body id="bodybg" class="adv">
<div class="bg">
<div id="stt"></div>
<div id="hdr"></div>
<div id="logo"><a href="../index.html"><img src="../images/style/logo.svg" alt="Math is Fun"></a></div>
<div id="advText">Advanced</div>
<div id="gtran">
<script>document.write(getTrans());</script>
</div>
<div id="adTopOuter" class="centerfull noprint">
<div id="adTop">
<script>document.write(getAdTop());</script>
</div>
</div>
<div id="adHide">
<div id="showAds1"><a href="javascript:showAds()">Show Ads</a></div>
<div id="hideAds1"><a href="javascript:hideAds()">Hide Ads</a><br>
<a href="../about-ads.html">About Ads</a></div>
</div>
<div id="menuWide" class="menu">
<script>document.write(getMenu(0));</script>
</div>
<div id="linkto">
<div id="linktort">
<script>document.write(getLinks());</script>
</div>
</div>
<div id="search" role="search">
<script>document.write(getSearch());</script>
</div>
<div id="menuSlim" class="menu">
<script>document.write(getMenu(1));</script>
</div>
<div id="menuTiny" class="menu">
<script>document.write(getMenu(2));</script>
</div>
<div id="extra"></div>
</div>
<div id="content" role="main"><!-- #BeginEditable "Body" -->
<h1 class="center">Chi-Square Test</h1>
<div style="float:right; margin: 0 0 5px 10px; background-color: #def;">
<table border="0">
<tr>
<td align="center"><img src="images/chi-square-group-a.jpg" width="300" height="218" alt="chi square groups" /></td>
</tr>
<tr>
<td align="center">Single: <span class="large">47</span> &nbsp; Married: <span class="large">71</span> &nbsp; Divorced: <span class="large">35</span></td>
</tr>
<tr>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td align="center"><img src="images/chi-square-group-b.jpg" width="300" height="207" alt="chi square groups" /></td>
</tr>
<tr>
<td align="center">Single: <span class="large">44</span> &nbsp; Married: <span class="large">85</span> &nbsp; Divorced: <span class="large">40</span></td>
</tr>
</table>
</div>
<h3>&nbsp;</h3>
<h3>Groups and Numbers</h3>
<p>You research two groups and put them in categories of single, married or divorced: </p>
<p>&nbsp;</p>
<p>The numbers are definitely different, but ... </p>
<ul>
<li>Is that just random chance?</li>
<li>Or have you found something interesting? </li>
</ul>
<p>&nbsp;</p>
<p class="larger">The <b>Chi-Square Test</b>&nbsp;gives a &quot;p&quot; value to help you decide! </p>
<div style="clear:both"></div>
<div class="example">
<h3>Example: &quot;Which holiday do you prefer?&quot;</h3>
<table border="0" align="center">
<tr>
<td width="90">&nbsp;</td>
<td width="90">Beach</td>
<td width="90">Cruise</td>
</tr>
<tr>
<td>Men</td>
<td>209</td>
<td>280</td>
</tr>
<tr>
<td>Women</td>
<td>225</td>
<td>248</td>
</tr>
</table>
<h3>Does Gender affect Preferred Holiday? </h3>
<p>If Gender (Man or Woman) <b>does</b> affect Preferred Holiday we say they are <b>dependent</b>.</p>
<p>By doing some special calculations (explained later), we come up with a &quot;p&quot; value:</p>
<p class="center large">p value is 0.132</p>
<p>Now, <b>p &lt; 0.05</b> is the usual test for <b>dependence</b>. </p>
<p>In this case <b>p is greater than 0.05</b>, so we believe the variables are <b>independent</b> (ie not linked together).</p>
<p>In other words Men and Women probably do <b>not</b> have a different preference for Beach Holidays or Cruises.</p>
<p>It was just random differences which we expect when collecting data.</p>
</div>
<h2>Understanding &quot;p&quot; Value</h2>
<p> &quot;p&quot; is the <a href="probability.html">probability</a> the variables are <b>independent</b>.</p>
<div class="center80">
<p>Imagine that the previous example was in fact two random samples of <b>Men</b> each time:</p>
<table border="0" align="center">
<tr>
<td width="180" align="center"><img src="images/chi-square1.gif" width="140" height="119" alt="chi square group 1" /></td>
<td width="180" align="center"><img src="images/chi-square2.gif" width="140" height="119" alt="chi square group 2" /></td>
</tr>
<tr>
<td align="center"><b>Men:</b><br>
Beach 209, Cruise 280 </td>
<td align="center"><b>Men:</b><br>
Beach 225, Cruise 248 </td>
</tr>
</table>
<p>Is it <b>likely</b> you would get such different results surveying Men each time?</p>
</div>
<p>Well the &quot;p&quot; value of <b>0.132</b> says that it really could happen every so often.</p>
<p><a href="survey-conducting.html">Surveys</a> are random after all. We expect slightly different results each time, right?</p>
<p>So most people want to see a <b>p</b> value less than <b>0.05</b> before they are happy to say the results show the groups have a different response.&nbsp;</p>
<p>Let's see another example:</p>
<div class="example">
<h3>Example: &quot;Which pet do you prefer?&quot;</h3>
<table border="0" align="center">
<tr>
<td width="90">&nbsp;</td>
<td width="90">Cat</td>
<td width="90">Dog</td>
</tr>
<tr>
<td>Men</td>
<td>207</td>
<td>282</td>
</tr>
<tr>
<td>Women</td>
<td>231</td>
<td>242</td>
</tr>
</table>
<p>By doing the calculations (shown later), we come up with:</p>
<p class="center large">P value is 0.043</p>
<p>In this case <b>p &lt; 0.05</b>, so this result is thought of as being &quot;significant&quot; meaning we think the variables are <b>not</b> independent. </p>
<p>In other words, because <b>0.043 &lt; 0.05</b> we think that Gender is linked to Pet Preference (Men and Women have different preferences for Cats and Dogs).</p>
</div>
<p><i>Just out of interest, notice that the numbers in our two examples are similar, but the resulting p-values are very different: <b>0.132</b> and <b>0.043</b>. This shows how sensitive the test is!</i></p>
<h2>Why p&lt;0.05 ?</h2>
<p>It is just a choice! <b>Using p&lt;0.05 is common</b>, but we could have chosen p&lt;0.01 to be even more sure that the groups behave differently,&nbsp;or any value really.</p>
<h2>Calculating P-Value</h2>
<p>So how do we calculate this p-value? We use the Chi-Square Test!</p>
<h2>Chi-Square Test</h2>
<div class="words">
<p>Note: <b>Chi</b> Sounds like &quot;Hi&quot; but with a <b>K</b>, so it sounds like &quot;<b>Ki</b> square&quot;</p>
<p>And Chi is the greek letter <span style="font: bold italic 20px 'Times New Roman', Times, serif;">&Chi;</span>, so we can also write it <span style="font: bold italic 20px 'Times New Roman', Times, serif;">&Chi;<sup>2</sup></span></p>
</div>
<p>Important points before we get started:</p>
<ul>
<li>This test only works for <b>categorical</b> data (data in categories), such as Gender {Men, Women} or color {Red, Yellow, Green, Blue} etc, but <b>not numerical</b>&nbsp;data such as height or weight.</li>
<li>The numbers must be large enough. Each entry must be <b>5</b> or more. In our example we have values such as 209, 282, etc, so we are good to go.</li>
</ul>
<h3>Our first step is to state our <b>hypotheses</b>:</h3>
<div class="words">
<p><b>Hypothesis</b>: A statement that might be true, which can then be tested.</p>
</div>
<p>The two <b>hypotheses</b> are.</p>
<ul>
<li>Gender and preference for cats or dogs are <b>independent</b>. </li>
<li>Gender and preference for cats or dogs are <b>not independent</b>.</li>
</ul>
<h3>Lay the data out in a table:</h3>
<table border="0" align="center">
<tr>
<td width="90">&nbsp;</td>
<td width="90" align="center">Cat</td>
<td width="90" align="center">Dog</td>
</tr>
<tr>
<td>Men</td>
<td align="center">207</td>
<td align="center">282</td>
</tr>
<tr>
<td>Women</td>
<td align="center">231</td>
<td align="center">242</td>
</tr>
</table>
<h3>Add up rows and columns:</h3>
<table border="0" align="center">
<tr>
<td width="90">&nbsp;</td>
<td width="90" align="center">Cat</td>
<td width="90" align="center">Dog</td>
<td width="90" align="center">&nbsp;</td>
</tr>
<tr>
<td>Men</td>
<td align="center">207</td>
<td align="center">282</td>
<td align="center" class="hilite">489</td>
</tr>
<tr>
<td>Women</td>
<td align="center">231</td>
<td align="center">242</td>
<td align="center" class="hilite">473</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center" class="hilite">438</td>
<td align="center" class="hilite">524</td>
<td align="center" class="hilite">962</td>
</tr>
</table>
<h3>Calculate &quot;Expected Value&quot; for each entry: </h3>
<p>Multiply each row total by each column total and divide by the overall total:</p>
<table border="0" align="center">
<tr>
<td width="90">&nbsp;</td>
<td width="120" align="center">Cat</td>
<td width="120" align="center">Dog</td>
<td width="90" align="center">&nbsp;</td>
</tr>
<tr>
<td>Men</td>
<td align="center" class="hilite"><span class="intbl"><em>489&times;438</em><strong>962</strong></span><!-- 489*438/962 --></td>
<td align="center" class="hilite"><span class="intbl"><em>489&times;524</em><strong>962</strong></span><!-- 489*524/962 --></td>
<td align="center">489</td>
</tr>
<tr>
<td>Women</td>
<td align="center" class="hilite"><span class="intbl"><em>473&times;438</em><strong>962</strong></span><!-- 473*438/962 --></td>
<td align="center" class="hilite"><span class="intbl"><em>473&times;524</em><strong>962</strong></span><!-- 473*524/962 --></td>
<td align="center">473</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">438</td>
<td align="center">524</td>
<td align="center">962</td>
</tr>
</table>
<p>Which gives us:</p>
<table border="0" align="center">
<tr>
<td width="90">&nbsp;</td>
<td width="120" align="center">Cat</td>
<td width="120" align="center">Dog</td>
<td width="90" align="center">&nbsp;</td>
</tr>
<tr>
<td>Men</td>
<td align="center" class="hilite">222.64</td>
<td align="center" class="hilite">266.36</td>
<td align="center">489</td>
</tr>
<tr>
<td>Women</td>
<td align="center" class="hilite">215.36</td>
<td align="center" class="hilite">257.64</td>
<td align="center">473</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">438</td>
<td align="center">524</td>
<td align="center">962</td>
</tr>
</table>
<h3>Subtract expected from observed, square it, then divide by expected:</h3>
<p>In other words, use formula <span class="intbl"><em>(O&minus;E)<sup>2</sup></em><strong>E</strong></span> where </p>
<ul>
<li>O = <b>Observed</b> (actual) value</li>
<li>E = <b>Expected</b> value </li>
</ul>
<table border="0" align="center">
<tr>
<td width="90">&nbsp;</td>
<td width="120" align="center">Cat</td>
<td width="120" align="center">Dog</td>
<td width="90" align="center">&nbsp;</td>
</tr>
<tr>
<td>Men</td>
<td align="center" class="hilite"><span class="intbl">
<em>(207&minus;222.64)<sup>2</sup></em>
<strong>222.64</strong>
</span></td>
<td align="center" class="hilite"><span class="intbl">
<em>(282&minus;266.36)<sup>2</sup></em>
<strong>266.36</strong>
</span></td>
<td align="center">489</td>
</tr>
<tr>
<td>Women</td>
<td align="center" class="hilite"><span class="intbl">
<em>(231&minus;215.36)<sup>2</sup></em>
<strong>215.36</strong>
</span></td>
<td align="center" class="hilite"><span class="intbl">
<em>(242&minus;257.64)<sup>2</sup></em>
<strong>257.64</strong>
</span></td>
<td align="center">473</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">438</td>
<td align="center">524</td>
<td align="center">962</td>
</tr>
</table>
<p>Which gets us:</p>
<table border="0" align="center">
<tr>
<td width="90">&nbsp;</td>
<td width="120" align="center">Cat</td>
<td width="120" align="center">Dog</td>
<td width="90" align="center">&nbsp;</td>
</tr>
<tr>
<td>Men</td>
<td align="center" class="hilite">1.099</td>
<td align="center" class="hilite">0.918</td>
<td align="center">489</td>
</tr>
<tr>
<td>Women</td>
<td align="center" class="hilite">1.136</td>
<td align="center" class="hilite">0.949</td>
<td align="center">473</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">438</td>
<td align="center">524</td>
<td align="center">962</td>
</tr>
</table>
<h3>Now add up those calculated values:</h3>
<p class="center">1.099 + 0.918 + 1.136 + 0.949&nbsp;= 4.102</p>
<p class="center large">Chi-Square is 4.102</p>
<h2>From Chi-Square to p</h2>
<h3>Degrees of Freedom</h3>
<p>First we need a &quot;Degree of Freedom&quot;</p>
<p class="center large">Degree of Freedom = (rows &minus; 1) &times; (columns &minus; 1)</p>
<div class="example">
<p>For our example we have 2 rows and 2 columns:</p>
<p class="center"> <b>DF</b> = (2 &minus; 1)(2 &minus; 1) = 1&times;1 = <b>1 </b></p>
</div>
<h3>p-value</h3>
<p>The rest of the calculation is difficult, so either look it up in&nbsp;a <a href="chi-square-table.html">table</a> or use the <a href="chi-square-calculator.html">Chi-Square Calculator</a>.</p>
<p>The result is:</p>
<p class="center large"> p = 0.04283</p>
<p>Done!</p>
<h2>Chi-Square Formula</h2>
<p>This is the formula for Chi-Square:</p>
<p class="center large"><span class="times"><i>&Chi;<sup>2</sup></i></span> = <span class="times" style="font-size:250%; vertical-align:middle;">&Sigma;</span><span class="intbl"><em>(O &minus; E)<sup>2</sup></em><strong>E</strong></span></p>
<!-- (O-E)^2/E -->
<ul>
<li><span class="times">&Sigma;</span> means to sum up (see <a href="../algebra/sigma-notation.html">Sigma Notation</a>)</li>
<li>O = each <b>Observed</b> (actual) value</li>
<li>E = each <b>Expected</b> value </li>
</ul>
<p>So we calculate <span class="intbl"><em>(O&minus;E)<sup>2</sup></em><strong>E</strong></span> for each pair of observed and expected values then sum them all up.</p>
<p>&nbsp;</p>
<div class="questions">
<script type="text/javascript">getQ(11372, 11373, 11374, 11375, 11376, 11377, 11378, 11379, 11380, 11381);</script>&nbsp;
</div>
<div class="related">
<a href="chi-square-calculator.html">Chi-Square Calculator</a> <a href="index.html">Data Index</a>
</div>
<!-- #EndEditable --></div>
<div id="adend" class="centerfull noprint">
<script>document.write(getAdEnd());</script>
</div>
<div id="footer" class="centerfull noprint">
<script>document.write(getFooter());</script>
</div>
<div id="copyrt">
Copyright &copy; 2019 MathsIsFun.com
</div>
<script>document.write(getBodyEnd());</script>
</body>
<!-- #EndTemplate -->
<!-- Mirrored from www.mathsisfun.com/data/chi-square-test.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 29 Oct 2022 00:31:56 GMT -->
</html>