Skip to content

Instantly share code, notes, and snippets.

@pree62
Created August 3, 2023 08:24
Show Gist options
  • Save pree62/9d41d3538542f4a67bbfe6e1c05553ef to your computer and use it in GitHub Desktop.
Save pree62/9d41d3538542f4a67bbfe6e1c05553ef to your computer and use it in GitHub Desktop.
!excelR/assignments/Gists/Hypothesis_Testing.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"id": "htVdIkB7x_JG",
"trusted": false
},
"cell_type": "code",
"source": "import pandas as pd\nimport scipy\nfrom scipy import stats\nfrom plotly import figure_factory as FF\n",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"id": "Fzu7VOJt3Pub"
},
"cell_type": "markdown",
"source": "# Question 1"
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"id": "GyTeTo2qytIz",
"outputId": "dd5db153-c9fc-4cdb-f555-5da468bb3fa9",
"trusted": false
},
"cell_type": "code",
"source": "df=pd.read_csv(\"Cutlets.csv\")\ndf",
"execution_count": null,
"outputs": [
{
"data": {
"text/html": "\n <div id=\"df-65dc8c9e-8654-4fbf-944e-d922de34ea70\">\n <div class=\"colab-df-container\">\n <div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>Unit A</th>\n <th>Unit B</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>6.8090</td>\n <td>6.7703</td>\n </tr>\n <tr>\n <th>1</th>\n <td>6.4376</td>\n <td>7.5093</td>\n </tr>\n <tr>\n <th>2</th>\n <td>6.9157</td>\n <td>6.7300</td>\n </tr>\n <tr>\n <th>3</th>\n <td>7.3012</td>\n <td>6.7878</td>\n </tr>\n <tr>\n <th>4</th>\n <td>7.4488</td>\n <td>7.1522</td>\n </tr>\n <tr>\n <th>5</th>\n <td>7.3871</td>\n <td>6.8110</td>\n </tr>\n <tr>\n <th>6</th>\n <td>6.8755</td>\n <td>7.2212</td>\n </tr>\n <tr>\n <th>7</th>\n <td>7.0621</td>\n <td>6.6606</td>\n </tr>\n <tr>\n <th>8</th>\n <td>6.6840</td>\n <td>7.2402</td>\n </tr>\n <tr>\n <th>9</th>\n <td>6.8236</td>\n <td>7.0503</td>\n </tr>\n <tr>\n <th>10</th>\n <td>7.3930</td>\n <td>6.8810</td>\n </tr>\n <tr>\n <th>11</th>\n <td>7.5169</td>\n <td>7.4059</td>\n </tr>\n <tr>\n <th>12</th>\n <td>6.9246</td>\n <td>6.7652</td>\n </tr>\n <tr>\n <th>13</th>\n <td>6.9256</td>\n <td>6.0380</td>\n </tr>\n <tr>\n <th>14</th>\n <td>6.5797</td>\n <td>7.1581</td>\n </tr>\n <tr>\n <th>15</th>\n <td>6.8394</td>\n <td>7.0240</td>\n </tr>\n <tr>\n <th>16</th>\n <td>6.5970</td>\n <td>6.6672</td>\n </tr>\n <tr>\n <th>17</th>\n <td>7.2705</td>\n <td>7.4314</td>\n </tr>\n <tr>\n <th>18</th>\n <td>7.2828</td>\n <td>7.3070</td>\n </tr>\n <tr>\n <th>19</th>\n <td>7.3495</td>\n <td>6.7478</td>\n </tr>\n <tr>\n <th>20</th>\n <td>6.9438</td>\n <td>6.8889</td>\n </tr>\n <tr>\n <th>21</th>\n <td>7.1560</td>\n <td>7.4220</td>\n </tr>\n <tr>\n <th>22</th>\n <td>6.5341</td>\n <td>6.5217</td>\n </tr>\n <tr>\n <th>23</th>\n <td>7.2854</td>\n <td>7.1688</td>\n </tr>\n <tr>\n <th>24</th>\n <td>6.9952</td>\n <td>6.7594</td>\n </tr>\n <tr>\n <th>25</th>\n <td>6.8568</td>\n <td>6.9399</td>\n </tr>\n <tr>\n <th>26</th>\n <td>7.2163</td>\n <td>7.0133</td>\n </tr>\n <tr>\n <th>27</th>\n <td>6.6801</td>\n <td>6.9182</td>\n </tr>\n <tr>\n <th>28</th>\n <td>6.9431</td>\n <td>6.3346</td>\n </tr>\n <tr>\n <th>29</th>\n <td>7.0852</td>\n <td>7.5459</td>\n </tr>\n <tr>\n <th>30</th>\n <td>6.7794</td>\n <td>7.0992</td>\n </tr>\n <tr>\n <th>31</th>\n <td>7.2783</td>\n <td>7.1180</td>\n </tr>\n <tr>\n <th>32</th>\n <td>7.1561</td>\n <td>6.6965</td>\n </tr>\n <tr>\n <th>33</th>\n <td>7.3943</td>\n <td>6.5780</td>\n </tr>\n <tr>\n <th>34</th>\n <td>6.9405</td>\n <td>7.3875</td>\n </tr>\n </tbody>\n</table>\n</div>\n <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-65dc8c9e-8654-4fbf-944e-d922de34ea70')\"\n title=\"Convert this dataframe to an interactive table.\"\n style=\"display:none;\">\n \n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n width=\"24px\">\n <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n </svg>\n </button>\n \n <style>\n .colab-df-container {\n display:flex;\n flex-wrap:wrap;\n gap: 12px;\n }\n\n .colab-df-convert {\n background-color: #E8F0FE;\n border: none;\n border-radius: 50%;\n cursor: pointer;\n display: none;\n fill: #1967D2;\n height: 32px;\n padding: 0 0 0 0;\n width: 32px;\n }\n\n .colab-df-convert:hover {\n background-color: #E2EBFA;\n box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n fill: #174EA6;\n }\n\n [theme=dark] .colab-df-convert {\n background-color: #3B4455;\n fill: #D2E3FC;\n }\n\n [theme=dark] .colab-df-convert:hover {\n background-color: #434B5C;\n box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n fill: #FFFFFF;\n }\n </style>\n\n <script>\n const buttonEl =\n document.querySelector('#df-65dc8c9e-8654-4fbf-944e-d922de34ea70 button.colab-df-convert');\n buttonEl.style.display =\n google.colab.kernel.accessAllowed ? 'block' : 'none';\n\n async function convertToInteractive(key) {\n const element = document.querySelector('#df-65dc8c9e-8654-4fbf-944e-d922de34ea70');\n const dataTable =\n await google.colab.kernel.invokeFunction('convertToInteractive',\n [key], {});\n if (!dataTable) return;\n\n const docLinkHtml = 'Like what you see? Visit the ' +\n '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n + ' to learn more about interactive tables.';\n element.innerHTML = '';\n dataTable['output_type'] = 'display_data';\n await google.colab.output.renderOutput(dataTable, element);\n const docLink = document.createElement('div');\n docLink.innerHTML = docLinkHtml;\n element.appendChild(docLink);\n }\n </script>\n </div>\n </div>\n ",
"text/plain": " Unit A Unit B\n0 6.8090 6.7703\n1 6.4376 7.5093\n2 6.9157 6.7300\n3 7.3012 6.7878\n4 7.4488 7.1522\n5 7.3871 6.8110\n6 6.8755 7.2212\n7 7.0621 6.6606\n8 6.6840 7.2402\n9 6.8236 7.0503\n10 7.3930 6.8810\n11 7.5169 7.4059\n12 6.9246 6.7652\n13 6.9256 6.0380\n14 6.5797 7.1581\n15 6.8394 7.0240\n16 6.5970 6.6672\n17 7.2705 7.4314\n18 7.2828 7.3070\n19 7.3495 6.7478\n20 6.9438 6.8889\n21 7.1560 7.4220\n22 6.5341 6.5217\n23 7.2854 7.1688\n24 6.9952 6.7594\n25 6.8568 6.9399\n26 7.2163 7.0133\n27 6.6801 6.9182\n28 6.9431 6.3346\n29 7.0852 7.5459\n30 6.7794 7.0992\n31 7.2783 7.1180\n32 7.1561 6.6965\n33 7.3943 6.5780\n34 6.9405 7.3875"
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "GHaPenray7BM",
"outputId": "4883f414-1864-4373-a486-bc4ef007acb8",
"trusted": false
},
"cell_type": "code",
"source": "stats.ttest_ind(df['Unit A'],df['Unit B'])",
"execution_count": null,
"outputs": [
{
"data": {
"text/plain": "Ttest_indResult(statistic=0.7228688704678063, pvalue=0.4722394724599501)"
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"id": "Hn8vbIDM1S7G"
},
"cell_type": "markdown",
"source": "significance level is 5%\n\n* H0 : There is no difference in diameter of cutlets\n* H1 : There is difference in diameter of cutlets\n\n\npvalue is 0.47 which is greater than 0.05. \n"
},
{
"metadata": {
"id": "XS865Jel2mae"
},
"cell_type": "markdown",
"source": "Therefore, Accept H0\nThere is no difference in diameter of cutlets"
},
{
"metadata": {
"id": "zkHR9PDp3Vps"
},
"cell_type": "markdown",
"source": "# Question 2"
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "VjT1jeUV3Zyp",
"outputId": "edd34b8d-45e6-49ba-e702-3f2a0dc3dba7",
"trusted": false
},
"cell_type": "code",
"source": "df2=pd.read_csv(\"LabTAT.csv\")\ndf2.head",
"execution_count": null,
"outputs": [
{
"data": {
"text/plain": "<bound method NDFrame.head of Laboratory 1 Laboratory 2 Laboratory 3 Laboratory 4\n0 185.35 165.53 176.70 166.13\n1 170.49 185.91 198.45 160.79\n2 192.77 194.92 201.23 185.18\n3 177.33 183.00 199.61 176.42\n4 193.41 169.57 204.63 152.60\n.. ... ... ... ...\n115 178.49 170.66 193.80 172.68\n116 176.08 183.98 215.25 177.64\n117 202.48 174.54 203.99 170.27\n118 182.40 197.18 194.52 150.87\n119 182.09 215.17 221.49 162.21\n\n[120 rows x 4 columns]>"
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"id": "0wYMHpA04kCI"
},
"cell_type": "markdown",
"source": "Significance level is 5%\n\n\n* H0 : All the means are same (all Lab's TAT averages are same)\n* H1 : Atleast one mean is different (Atleast 1 Lab's Average TAT is different)\n\n"
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "VT5EmKyh5m5E",
"outputId": "9d5611cb-e5ac-41ff-e289-cae396f27b78",
"trusted": false
},
"cell_type": "code",
"source": "#Calculating pvalue with the help of F-ratio\nstats.f_oneway(df2.iloc[:,0],df2.iloc[:,1],df2.iloc[:,2],df2.iloc[:,3])",
"execution_count": null,
"outputs": [
{
"data": {
"text/plain": "F_onewayResult(statistic=118.70421654401437, pvalue=2.1156708949992414e-57)"
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"id": "RcKoLF2w7W88"
},
"cell_type": "markdown",
"source": "2.11 * 10 power -57 which almost 0 and less than alpha value (0.05)"
},
{
"metadata": {
"id": "HEsKpAR47sua"
},
"cell_type": "markdown",
"source": "There we accept alternate hypothesis (H1) and reject null hypothesis (H0). Atleast one mean is different (Atleast 1 Lab's Average TAT is different)."
},
{
"metadata": {
"id": "J4dHl9848g_-"
},
"cell_type": "markdown",
"source": "# Question 3"
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "uWVzmBPM9PLj",
"outputId": "3410a9cd-590f-426c-92f4-ccd6a855770d",
"trusted": false
},
"cell_type": "code",
"source": "df3=pd.read_csv(\"BuyerRatio.csv\")\ndf3.head",
"execution_count": null,
"outputs": [
{
"data": {
"text/plain": "<bound method NDFrame.head of Observed Values East West North South\n0 Males 50 142 131 70\n1 Females 435 1523 1356 750>"
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"id": "T3deixX3DEZh"
},
"cell_type": "markdown",
"source": "\n\n* H0 : All proportions are equal\n* H1 : All proportions are not equal\n\n"
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "eth9PpIK9va4",
"outputId": "86904232-7a26-4fbd-b25b-ab76f4abed52",
"trusted": false
},
"cell_type": "code",
"source": "# using chi-square Test\nchi_results=stats.chi2_contingency([df3[\"East\"], df3[\"West\"], df3[\"North\"], df3[\"South\"]])\nchi_results",
"execution_count": null,
"outputs": [
{
"data": {
"text/plain": "(1.5959455386610577,\n 0.6603094907091882,\n 3,\n array([[ 42.76531299, 442.23468701],\n [ 146.81287862, 1518.18712138],\n [ 131.11756787, 1355.88243213],\n [ 72.30424052, 747.69575948]]))"
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "XX8A8RPaCV5t",
"outputId": "8c04149c-5261-426a-ae3b-906216046104",
"trusted": false
},
"cell_type": "code",
"source": "chi_square=[['','Test Statistic','p-value'],['Sample Data',chi_results[0],chi_results[1]]]\nchi_square",
"execution_count": null,
"outputs": [
{
"data": {
"text/plain": "[['', 'Test Statistic', 'p-value'],\n ['Sample Data', 1.5959455386610577, 0.6603094907091882]]"
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 127
},
"id": "NfiYYOnGB6Oj",
"outputId": "64a44472-69c3-41ea-f281-08da675609bf",
"trusted": false
},
"cell_type": "code",
"source": "FF.create_table(chi_square,index=True)",
"execution_count": null,
"outputs": [
{
"data": {
"text/html": "<html>\n<head><meta charset=\"utf-8\" /></head>\n<body>\n <div> <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script> <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n <script src=\"https://cdn.plot.ly/plotly-2.8.3.min.js\"></script> <div id=\"231d7e6c-9a43-4eed-b9ba-360b41eb3e17\" class=\"plotly-graph-div\" style=\"height:110px; width:100%;\"></div> <script type=\"text/javascript\"> window.PLOTLYENV=window.PLOTLYENV || {}; if (document.getElementById(\"231d7e6c-9a43-4eed-b9ba-360b41eb3e17\")) { Plotly.newPlot( \"231d7e6c-9a43-4eed-b9ba-360b41eb3e17\", [{\"colorscale\":[[0,\"#00083e\"],[0.5,\"#ededee\"],[1,\"#ffffff\"]],\"hoverinfo\":\"none\",\"opacity\":0.75,\"showscale\":false,\"z\":[[0,0,0],[0,0.5,0.5]],\"type\":\"heatmap\"}], {\"annotations\":[{\"align\":\"left\",\"font\":{\"color\":\"#ffffff\"},\"showarrow\":false,\"text\":\"<b></b>\",\"x\":-0.45,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":0,\"yref\":\"y\"},{\"align\":\"left\",\"font\":{\"color\":\"#ffffff\"},\"showarrow\":false,\"text\":\"<b>Test Statistic</b>\",\"x\":0.55,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":0,\"yref\":\"y\"},{\"align\":\"left\",\"font\":{\"color\":\"#ffffff\"},\"showarrow\":false,\"text\":\"<b>p-value</b>\",\"x\":1.55,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":0,\"yref\":\"y\"},{\"align\":\"left\",\"font\":{\"color\":\"#ffffff\"},\"showarrow\":false,\"text\":\"<b>Sample Data</b>\",\"x\":-0.45,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":1,\"yref\":\"y\"},{\"align\":\"left\",\"font\":{\"color\":\"#000000\"},\"showarrow\":false,\"text\":\"1.5959455386610577\",\"x\":0.55,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":1,\"yref\":\"y\"},{\"align\":\"left\",\"font\":{\"color\":\"#000000\"},\"showarrow\":false,\"text\":\"0.6603094907091882\",\"x\":1.55,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":1,\"yref\":\"y\"}],\"height\":110,\"margin\":{\"b\":0,\"l\":0,\"r\":0,\"t\":0},\"xaxis\":{\"dtick\":1,\"gridwidth\":2,\"showticklabels\":false,\"tick0\":-0.5,\"ticks\":\"\",\"zeroline\":false},\"yaxis\":{\"autorange\":\"reversed\",\"dtick\":1,\"gridwidth\":2,\"showticklabels\":false,\"tick0\":0.5,\"ticks\":\"\",\"zeroline\":false},\"template\":{\"data\":{\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"choropleth\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"choropleth\"}],\"contour\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"contour\"}],\"contourcarpet\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"contourcarpet\"}],\"heatmap\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"heatmap\"}],\"heatmapgl\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"heatmapgl\"}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"histogram2d\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"histogram2d\"}],\"histogram2dcontour\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"histogram2dcontour\"}],\"mesh3d\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"mesh3d\"}],\"parcoords\":[{\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"parcoords\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}],\"scatter\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatter\"}],\"scatter3d\":[{\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatter3d\"}],\"scattercarpet\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattercarpet\"}],\"scattergeo\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattergeo\"}],\"scattergl\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattergl\"}],\"scattermapbox\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattermapbox\"}],\"scatterpolar\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterpolar\"}],\"scatterpolargl\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterpolargl\"}],\"scatterternary\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterternary\"}],\"surface\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"surface\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}]},\"layout\":{\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"autotypenumbers\":\"strict\",\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"geo\":{\"bgcolor\":\"white\",\"lakecolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"showlakes\":true,\"showland\":true,\"subunitcolor\":\"white\"},\"hoverlabel\":{\"align\":\"left\"},\"hovermode\":\"closest\",\"mapbox\":{\"style\":\"light\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"bgcolor\":\"#E5ECF6\",\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"ternary\":{\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"bgcolor\":\"#E5ECF6\",\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"title\":{\"x\":0.05},\"xaxis\":{\"automargin\":true,\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"zerolinewidth\":2},\"yaxis\":{\"automargin\":true,\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"zerolinewidth\":2}}}}, {\"responsive\": true} ).then(function(){\n \nvar gd = document.getElementById('231d7e6c-9a43-4eed-b9ba-360b41eb3e17');\nvar x = new MutationObserver(function (mutations, observer) {{\n var display = window.getComputedStyle(gd).display;\n if (!display || display === 'none') {{\n console.log([gd, 'removed!']);\n Plotly.purge(gd);\n observer.disconnect();\n }}\n}});\n\n// Listen for the removal of the full notebook cells\nvar notebookContainer = gd.closest('#notebook-container');\nif (notebookContainer) {{\n x.observe(notebookContainer, {childList: true});\n}}\n\n// Listen for the clearing of the current output cell\nvar outputEl = gd.closest('.output');\nif (outputEl) {{\n x.observe(outputEl, {childList: true});\n}}\n\n }) }; </script> </div>\n</body>\n</html>"
},
"metadata": {},
"output_type": "display_data"
}
]
},
{
"metadata": {
"id": "qL0oIqFaB1jK"
},
"cell_type": "markdown",
"source": "p-value is 0.66 which is greater than 0.05.\n"
},
{
"metadata": {
"id": "urUYvn1YDo0S"
},
"cell_type": "markdown",
"source": "Accept null hypothesis. All proportions are equal"
},
{
"metadata": {
"id": "i_LBEgOLEh8s"
},
"cell_type": "markdown",
"source": "#Question 4\n"
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "FzkepnkTElsv",
"outputId": "2885e439-13e6-4c1a-eb15-ed201a9fbe61",
"trusted": false
},
"cell_type": "code",
"source": "df4=pd.read_csv(\"Costomer+OrderForm.csv\")\ndf4.head",
"execution_count": null,
"outputs": [
{
"data": {
"text/plain": "<bound method NDFrame.head of Phillippines Indonesia Malta India\n0 Error Free Error Free Defective Error Free\n1 Error Free Error Free Error Free Defective\n2 Error Free Defective Defective Error Free\n3 Error Free Error Free Error Free Error Free\n4 Error Free Error Free Defective Error Free\n.. ... ... ... ...\n295 Error Free Error Free Error Free Error Free\n296 Error Free Error Free Error Free Error Free\n297 Error Free Error Free Defective Error Free\n298 Error Free Error Free Error Free Error Free\n299 Error Free Defective Defective Error Free\n\n[300 rows x 4 columns]>"
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"id": "V4tdfWEWG7X0"
},
"cell_type": "markdown",
"source": "\n\n* H0 : Defective % does not vary by centre \n* H1 : Defective % varies by centre\n\n"
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "F0oD9pP9ExIN",
"outputId": "63c9ba1d-37a7-4a10-cdce-8ea4850ad4ba",
"trusted": false
},
"cell_type": "code",
"source": "# using chi-square Test\nchi_results=stats.chi2_contingency([df4[\"Phillippines\"].value_counts(),df4[\"Indonesia\"].value_counts(),df4[\"Malta\"].value_counts(),df4[\"India\"].value_counts()])\nchi_results",
"execution_count": null,
"outputs": [
{
"data": {
"text/plain": "(3.8589606858203545, 0.2771020991233144, 3, array([[271.75, 28.25],\n [271.75, 28.25],\n [271.75, 28.25],\n [271.75, 28.25]]))"
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "HdPxUgGPFyRl",
"outputId": "5d2db4a5-d3c8-4421-eb43-05f8120b3561",
"trusted": false
},
"cell_type": "code",
"source": "chi_square=[[\"\",\"Test statistic\",\"p-value\"],[\"Sample Data\",chi_results[0],chi_results[1]]]\nchi_square",
"execution_count": null,
"outputs": [
{
"data": {
"text/plain": "[['', 'Test statistic', 'p-value'],\n ['Sample Data', 3.8589606858203545, 0.2771020991233144]]"
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 127
},
"id": "ye5SR_7oGVQ4",
"outputId": "d722dace-0dc3-463a-a79c-c91c40f68370",
"trusted": false
},
"cell_type": "code",
"source": "FF.create_table(chi_square,index=True)",
"execution_count": null,
"outputs": [
{
"data": {
"text/html": "<html>\n<head><meta charset=\"utf-8\" /></head>\n<body>\n <div> <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script> <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n <script src=\"https://cdn.plot.ly/plotly-2.8.3.min.js\"></script> <div id=\"82b5f928-cfa5-4011-a002-122dda9637fc\" class=\"plotly-graph-div\" style=\"height:110px; width:100%;\"></div> <script type=\"text/javascript\"> window.PLOTLYENV=window.PLOTLYENV || {}; if (document.getElementById(\"82b5f928-cfa5-4011-a002-122dda9637fc\")) { Plotly.newPlot( \"82b5f928-cfa5-4011-a002-122dda9637fc\", [{\"colorscale\":[[0,\"#00083e\"],[0.5,\"#ededee\"],[1,\"#ffffff\"]],\"hoverinfo\":\"none\",\"opacity\":0.75,\"showscale\":false,\"z\":[[0,0,0],[0,0.5,0.5]],\"type\":\"heatmap\"}], {\"annotations\":[{\"align\":\"left\",\"font\":{\"color\":\"#ffffff\"},\"showarrow\":false,\"text\":\"<b></b>\",\"x\":-0.45,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":0,\"yref\":\"y\"},{\"align\":\"left\",\"font\":{\"color\":\"#ffffff\"},\"showarrow\":false,\"text\":\"<b>Test statistic</b>\",\"x\":0.55,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":0,\"yref\":\"y\"},{\"align\":\"left\",\"font\":{\"color\":\"#ffffff\"},\"showarrow\":false,\"text\":\"<b>p-value</b>\",\"x\":1.55,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":0,\"yref\":\"y\"},{\"align\":\"left\",\"font\":{\"color\":\"#ffffff\"},\"showarrow\":false,\"text\":\"<b>Sample Data</b>\",\"x\":-0.45,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":1,\"yref\":\"y\"},{\"align\":\"left\",\"font\":{\"color\":\"#000000\"},\"showarrow\":false,\"text\":\"3.8589606858203545\",\"x\":0.55,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":1,\"yref\":\"y\"},{\"align\":\"left\",\"font\":{\"color\":\"#000000\"},\"showarrow\":false,\"text\":\"0.2771020991233144\",\"x\":1.55,\"xanchor\":\"left\",\"xref\":\"x\",\"y\":1,\"yref\":\"y\"}],\"height\":110,\"margin\":{\"b\":0,\"l\":0,\"r\":0,\"t\":0},\"xaxis\":{\"dtick\":1,\"gridwidth\":2,\"showticklabels\":false,\"tick0\":-0.5,\"ticks\":\"\",\"zeroline\":false},\"yaxis\":{\"autorange\":\"reversed\",\"dtick\":1,\"gridwidth\":2,\"showticklabels\":false,\"tick0\":0.5,\"ticks\":\"\",\"zeroline\":false},\"template\":{\"data\":{\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"choropleth\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"choropleth\"}],\"contour\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"contour\"}],\"contourcarpet\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"contourcarpet\"}],\"heatmap\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"heatmap\"}],\"heatmapgl\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"heatmapgl\"}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"histogram2d\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"histogram2d\"}],\"histogram2dcontour\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"histogram2dcontour\"}],\"mesh3d\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"mesh3d\"}],\"parcoords\":[{\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"parcoords\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}],\"scatter\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatter\"}],\"scatter3d\":[{\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatter3d\"}],\"scattercarpet\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattercarpet\"}],\"scattergeo\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattergeo\"}],\"scattergl\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattergl\"}],\"scattermapbox\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattermapbox\"}],\"scatterpolar\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterpolar\"}],\"scatterpolargl\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterpolargl\"}],\"scatterternary\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterternary\"}],\"surface\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"surface\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}]},\"layout\":{\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"autotypenumbers\":\"strict\",\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"geo\":{\"bgcolor\":\"white\",\"lakecolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"showlakes\":true,\"showland\":true,\"subunitcolor\":\"white\"},\"hoverlabel\":{\"align\":\"left\"},\"hovermode\":\"closest\",\"mapbox\":{\"style\":\"light\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"bgcolor\":\"#E5ECF6\",\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"ternary\":{\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"bgcolor\":\"#E5ECF6\",\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"title\":{\"x\":0.05},\"xaxis\":{\"automargin\":true,\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"zerolinewidth\":2},\"yaxis\":{\"automargin\":true,\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"zerolinewidth\":2}}}}, {\"responsive\": true} ).then(function(){\n \nvar gd = document.getElementById('82b5f928-cfa5-4011-a002-122dda9637fc');\nvar x = new MutationObserver(function (mutations, observer) {{\n var display = window.getComputedStyle(gd).display;\n if (!display || display === 'none') {{\n console.log([gd, 'removed!']);\n Plotly.purge(gd);\n observer.disconnect();\n }}\n}});\n\n// Listen for the removal of the full notebook cells\nvar notebookContainer = gd.closest('#notebook-container');\nif (notebookContainer) {{\n x.observe(notebookContainer, {childList: true});\n}}\n\n// Listen for the clearing of the current output cell\nvar outputEl = gd.closest('.output');\nif (outputEl) {{\n x.observe(outputEl, {childList: true});\n}}\n\n }) }; </script> </div>\n</body>\n</html>"
},
"metadata": {},
"output_type": "display_data"
}
]
},
{
"metadata": {
"id": "JPjVghYgGcpf"
},
"cell_type": "markdown",
"source": "p-value is 0.277 which is greater than alpha value (0.05)\nAccept null hypothesis"
},
{
"metadata": {
"id": "6EFnVpIUG4Pg"
},
"cell_type": "markdown",
"source": "Accept H0, defective % does not varies by centre"
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3 (ipykernel)",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.9.13",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "!excelR/assignments/Gists/Hypothesis_Testing.ipynb",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment