{ "cells": [ { "cell_type": "code", "execution_count": 4, "id": "7633578e-705d-4581-a4c5-aeee00006bd4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "There are 254251200 permutations.\n" ] } ], "source": [ "# Permutations\n", "import numpy as np\n", "from scipy.special import perm\n", "\n", "N = 50\n", "k = 5\n", "p = perm(N, k, exact=True)\n", "print(f\"There are {p} permutations.\")" ] }, { "cell_type": "code", "execution_count": 6, "id": "050b72b4-628a-4d72-99d2-80deef2ad277", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "There are 2118760 combinations.\n" ] } ], "source": [ "# Combinations\n", "import numpy as np\n", "from scipy.special import comb\n", "\n", "N = 50\n", "r = 5\n", "c = comb(N, r, exact=True)\n", "print(f\"There are {c} combinations.\")" ] }, { "cell_type": "code", "execution_count": 10, "id": "6a148101-89c9-4da4-8524-7971c46ea096", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "There is a 0.9997198781738114 probability.\n" ] } ], "source": [ "# Birthday problem\n", "import numpy as np\n", "from scipy.special import perm\n", "\n", "N = 365 # number of days\n", "k = 75 # Number of people registered\n", "\n", "p = perm(N, k, exact=True)\n", "prob_Eprime = p / (N**k)\n", "prob_E = 1-prob_Eprime\n", "\n", "print(f\"There is a {prob_E} probability.\")" ] }, { "cell_type": "code", "execution_count": null, "id": "80e1981c-0da9-4827-ac66-bd216cb592f1", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.9" } }, "nbformat": 4, "nbformat_minor": 5 }