{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyMDnTJr/59RywnewRuriT9P"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"id":"9faOB2ke1xhX","executionInfo":{"status":"ok","timestamp":1717757656597,"user_tz":-330,"elapsed":1732,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}}},"outputs":[],"source":["from statsmodels.stats.proportion import proportions_ztest\n","import numpy as np"]},{"cell_type":"code","source":["alpha = 0.05\n","Instawyes, Instaw = (130, 250)\n","Instamyes, Instam  = (150, 350)"],"metadata":{"id":"mbJ-jp491zwr","executionInfo":{"status":"ok","timestamp":1717757656598,"user_tz":-330,"elapsed":22,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}}},"execution_count":2,"outputs":[]},{"cell_type":"code","source":["print(\"Part A: state the null and alternative hypotheses for this problem\\n \")\n","print(\"\\tH0: Proportion of Females on Insta =  Proportion of males on Insta\")\n","print(\"\\tH1:  Proportion of Females on Insta =!  Proportion of males on Insta \\n\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"U23GtFBO1z0U","executionInfo":{"status":"ok","timestamp":1717757656598,"user_tz":-330,"elapsed":20,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"7cf4a735-670c-4c9e-cb78-53d4cbaaafa9"},"execution_count":3,"outputs":[{"output_type":"stream","name":"stdout","text":["Part A: state the null and alternative hypotheses for this problem\n"," \n","\tH0: Proportion of Females on Insta =  Proportion of males on Insta\n","\tH1:  Proportion of Females on Insta =!  Proportion of males on Insta \n","\n"]}]},{"cell_type":"code","source":["successes = np.array([Instawyes, Instamyes])\n","samples = np.array([Instaw, Instam])\n","stat, p_value = proportions_ztest(count=successes, nobs=samples,  alternative='two-sided')\n","\n","print('z_stat: %0.3f, p_value: %0.3f' % (stat, p_value))\n","if p_value < alpha:\n","   print (\"Reject the null hypothesis\")\n","else:\n","   print (\"Do not Reject the null hypothesis\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"aB_4KNpV1z3-","executionInfo":{"status":"ok","timestamp":1717757656598,"user_tz":-330,"elapsed":15,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"7268781c-914c-4a74-af40-62017a930f37"},"execution_count":4,"outputs":[{"output_type":"stream","name":"stdout","text":["z_stat: 2.213, p_value: 0.027\n","Reject the null hypothesis\n"]}]},{"cell_type":"code","source":["print(\"Part B: state the null and alternative hypotheses for this problem\\n \")\n","print(\"\\tH0: Proportion of Females on Insta <=  Proportion of males on Insta\")\n","print(\"\\tH1:  Proportion of Females on Insta >  Proportion of males on Insta \\n\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"ulS1BLQu18AR","executionInfo":{"status":"ok","timestamp":1717757656598,"user_tz":-330,"elapsed":11,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"d35ac422-b985-43c6-88e8-68c83ebb299d"},"execution_count":5,"outputs":[{"output_type":"stream","name":"stdout","text":["Part B: state the null and alternative hypotheses for this problem\n"," \n","\tH0: Proportion of Females on Insta <=  Proportion of males on Insta\n","\tH1:  Proportion of Females on Insta >  Proportion of males on Insta \n","\n"]}]},{"cell_type":"code","source":["successes = np.array([Instawyes, Instamyes])\n","samples = np.array([Instaw, Instam])\n","stat, p_value = proportions_ztest(count=successes, nobs=samples,  alternative='larger')\n","\n","print('z_stat: %0.3f, p_value: %0.3f' % (stat, p_value))\n","if p_value < alpha:\n","   print (\"Reject the null hypothesis\")\n","else:\n","   print (\"Do not Reject the null hypothesis\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"0bSKw8w718Dp","executionInfo":{"status":"ok","timestamp":1717757656599,"user_tz":-330,"elapsed":8,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"a30b46b2-aab3-414f-834f-eca3af992c79"},"execution_count":6,"outputs":[{"output_type":"stream","name":"stdout","text":["z_stat: 2.213, p_value: 0.013\n","Reject the null hypothesis\n"]}]}]}