{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyOGN1yzWDx7waAPE7W9pi/T"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"id":"JzG5QJIoXa9p","executionInfo":{"status":"ok","timestamp":1717751377267,"user_tz":-330,"elapsed":1346,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}}},"outputs":[],"source":["import scipy.stats as stats\n","import matplotlib.pyplot as plt\n","import math\n","import numpy as np\n","from scipy.stats import expon"]},{"cell_type":"code","source":["# Plot the probability density function (PDF)\n","avtime=21\n","x = np.linspace(0, 100, 100)\n","pdf = expon.pdf(x, scale=avtime)\n","plt.plot(x, pdf, 'r', label='PDF')\n","plt.xlabel('Value')\n","plt.ylabel('Probability')\n","plt.legend()\n","plt.title('Exponential Distribution')\n","plt.show()\n"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":472},"id":"y9KxdmRvXeVv","executionInfo":{"status":"ok","timestamp":1717751378078,"user_tz":-330,"elapsed":813,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"260502e0-5c2e-4be1-a3e8-6f9a723ffdf2"},"execution_count":2,"outputs":[{"output_type":"display_data","data":{"text/plain":["<Figure size 640x480 with 1 Axes>"],"image/png":"[encoded data, 28332 characters]\n"},"metadata":{}}]},{"cell_type":"code","source":["avtime=21\n","x16=16\n","x24=24\n","cdfx16 = expon.cdf(x16, scale=avtime)\n","print(f\"The probability of customer spends time less than {x16} minutes: {cdfx16}\")\n","cdfx24 = expon.cdf(x24, scale=avtime)\n","print(f\"The probability of customer spends time less than {x24} minutes: {cdfx24}\")\n","print(\"probability that customer spends time between 16 and 24 minutes is equal to\", cdfx24-cdfx16)\n","\n"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"QRhaQ9osXeZB","executionInfo":{"status":"ok","timestamp":1717751378078,"user_tz":-330,"elapsed":8,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"b99d70ee-4450-47db-a5db-c306ae636588"},"execution_count":3,"outputs":[{"output_type":"stream","name":"stdout","text":["The probability of customer spends time less than 16 minutes: 0.5332235183483186\n","The probability of customer spends time less than 24 minutes: 0.6810934426760296\n","probability that customer spends time between 16 and 24 minutes is equal to 0.14786992432771096\n"]}]},{"cell_type":"code","source":["x18=18\n","x25=25\n","cdfx18 = expon.sf(x18, scale=avtime)\n","print(f\"The probability of customer spends time more than {x18} minutes: {cdfx18}\")\n","cdfx25 = expon.sf(x25, scale=avtime)\n","print(f\"The probability of customer spends time more than {x25} minutes: {cdfx25}\")\n"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"Y4tdduGkXecY","executionInfo":{"status":"ok","timestamp":1717751378079,"user_tz":-330,"elapsed":6,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"009cfc38-9097-48b3-b605-bb27c3580642"},"execution_count":4,"outputs":[{"output_type":"stream","name":"stdout","text":["The probability of customer spends time more than 18 minutes: 0.42437284567695\n","The probability of customer spends time more than 25 minutes: 0.30407643128483336\n"]}]},{"cell_type":"code","source":[],"metadata":{"id":"KsROL0PKXefi","executionInfo":{"status":"ok","timestamp":1717751378079,"user_tz":-330,"elapsed":4,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}}},"execution_count":4,"outputs":[]}]}