{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyP8yAZoEEfDiECJdanTsA0n"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"id":"vLfO0ZLMRV28","executionInfo":{"status":"ok","timestamp":1717748313989,"user_tz":-330,"elapsed":1373,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}}},"outputs":[],"source":["import scipy.stats as stats\n","import numpy as np"]},{"cell_type":"code","execution_count":2,"metadata":{"id":"jc-DDb6fRXa-","executionInfo":{"status":"ok","timestamp":1717748313990,"user_tz":-330,"elapsed":20,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}}},"outputs":[],"source":["p=.8\n","n=7"]},{"cell_type":"code","source":["##answer a  ... r=1,1,2,3,4 p=.8     n=7\n","ansa=stats.binom.pmf(4,n,p)\n","print(\"ansa   {0:.2f}.\".format(ansa))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"KU0mKTb-Rb3c","executionInfo":{"status":"ok","timestamp":1717748313990,"user_tz":-330,"elapsed":19,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"b3f2d6f6-fa9a-43a8-9ce6-5e5ff36fa7c8"},"execution_count":3,"outputs":[{"output_type":"stream","name":"stdout","text":["ansa   0.11.\n"]}]},{"cell_type":"code","source":["ansb=1-stats.binom.cdf(4,n,p)\n","print(\"ansb   {0:.2f}.\".format(ansb))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"9X8QerdaRb0U","executionInfo":{"status":"ok","timestamp":1717748313990,"user_tz":-330,"elapsed":16,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"97e8ddac-d4c8-47c1-daac-d59afc646e29"},"execution_count":4,"outputs":[{"output_type":"stream","name":"stdout","text":["ansb   0.85.\n"]}]},{"cell_type":"code","source":["ansc=stats.binom.pmf(0,n,p)+stats.binom.pmf(1,n,p)+stats.binom.pmf(2,n,p)+stats.binom.pmf(3,n,p)+stats.binom.pmf(4,n,p)\n","print(\"ansc   {0:.2f}.\".format(ansc))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"k3v-EDY_RbxI","executionInfo":{"status":"ok","timestamp":1717748313990,"user_tz":-330,"elapsed":14,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"8dfee5d6-0f7f-43f5-db5e-028389140d4d"},"execution_count":5,"outputs":[{"output_type":"stream","name":"stdout","text":["ansc   0.15.\n"]}]},{"cell_type":"code","source":["m, v, s, k = stats.binom.stats(n, p, moments='mvsk')\n","print(\"mean    {0:.2f}.\".format(m))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"K3GkVB0ARbtY","executionInfo":{"status":"ok","timestamp":1717748313990,"user_tz":-330,"elapsed":12,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"b26f8dbc-b0c3-4f8d-fc04-b76d387b05bf"},"execution_count":6,"outputs":[{"output_type":"stream","name":"stdout","text":["mean    5.60.\n"]}]}]}