{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyMaN5v0kj+VH7C7xt1Zskan"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"id":"gtqRMNCysPW-","executionInfo":{"status":"ok","timestamp":1717753049808,"user_tz":-330,"elapsed":1909,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}}},"outputs":[],"source":["import scipy.stats as st\n","import numpy as np\n","import matplotlib.pyplot as plt\n","import statsmodels.stats.api as sms"]},{"cell_type":"code","source":["data = [15, 16, 17, 18, 13, 14, 15, 21, 25, 23, 23, 25, 26, 26, 27]\n","mean= np.mean(data)\n","sd= np.std(data)\n","n=len(data)\n","t_critical = st.t.ppf(q = 0.975, df=n-1)\n","sem=st.sem(data)\n","margin_of_error = t_critical * sem"],"metadata":{"id":"eq0xxBmcsv3R","executionInfo":{"status":"ok","timestamp":1717753049808,"user_tz":-330,"elapsed":20,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}}},"execution_count":2,"outputs":[]},{"cell_type":"code","source":["round(sem,3)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"WZJWVjuwsv6d","executionInfo":{"status":"ok","timestamp":1717753049809,"user_tz":-330,"elapsed":19,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"68edc4cf-5bef-421f-d159-65667c133cb9"},"execution_count":3,"outputs":[{"output_type":"execute_result","data":{"text/plain":["1.296"]},"metadata":{},"execution_count":3}]},{"cell_type":"code","source":["sem1=sd/(n-1)**.5\n","round(sem1,3)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"x4_pCUVQsv9Y","executionInfo":{"status":"ok","timestamp":1717753049809,"user_tz":-330,"elapsed":12,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"83ffe78c-0002-41db-c8c6-017a552bd879"},"execution_count":4,"outputs":[{"output_type":"execute_result","data":{"text/plain":["1.296"]},"metadata":{},"execution_count":4}]},{"cell_type":"code","source":["print(\"Part A Answer: Mean               :\", mean)\n","print(\"Part B Answer: Standard Deviation :\", sd)\n","print(\"Count                             :\", n)\n","print(\"Degrees of Freedom                :\", n-1)\n","print(\"t-critical value                  :\",t_critical)\n","print(\"Standard error of mean            :\", sem)\n","print(\"Part C Answer: Margin_of_Error    :\", margin_of_error)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"FqtuACa9sv_9","executionInfo":{"status":"ok","timestamp":1717753049809,"user_tz":-330,"elapsed":10,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"e6c0a4e5-e845-4d38-a855-286ab5acbefb"},"execution_count":5,"outputs":[{"output_type":"stream","name":"stdout","text":["Part A Answer: Mean               : 20.266666666666666\n","Part B Answer: Standard Deviation : 4.850658603621667\n","Count                             : 15\n","Degrees of Freedom                : 14\n","t-critical value                  : 2.1447866879169273\n","Standard error of mean            : 1.2963930424971126\n","Part C Answer: Margin_of_Error    : 2.7804865398559304\n"]}]},{"cell_type":"code","source":["CI = sms.DescrStatsW(data).tconfint_mean()\n","CI"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"WEEZRV57KMio","executionInfo":{"status":"ok","timestamp":1717753049809,"user_tz":-330,"elapsed":8,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"91f8bc61-9d66-4895-a3fb-6639c5b47164"},"execution_count":6,"outputs":[{"output_type":"execute_result","data":{"text/plain":["(17.486180126810734, 23.047153206522598)"]},"metadata":{},"execution_count":6}]},{"cell_type":"code","source":["CI = sms.DescrStatsW(data).tconfint_mean()\n","CI95= (round(CI[0], 2), round(CI[1], 2))\n","print(\"Answer of Part D                  :\")\n","print(\"95% Confidence Interval of Data   :\", CI95)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"gED_kqqrEcAc","executionInfo":{"status":"ok","timestamp":1717753049809,"user_tz":-330,"elapsed":6,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"69ec47f4-d1a0-479c-d4cd-68905c2ffc89"},"execution_count":7,"outputs":[{"output_type":"stream","name":"stdout","text":["Answer of Part D                  :\n","95% Confidence Interval of Data   : (17.49, 23.05)\n"]}]},{"cell_type":"code","source":[],"metadata":{"id":"wEhGV6SCENqe","executionInfo":{"status":"ok","timestamp":1717753049809,"user_tz":-330,"elapsed":4,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}}},"execution_count":7,"outputs":[]}]}