510 lines
238 KiB
Plaintext
510 lines
238 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "db958d91-e3a0-4c3b-95d9-034a6ec30e8d",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"source": [
|
||
|
"# Monte Carlo Simulationen"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"id": "45a2a6a7-7744-493f-becd-ca242a60f3e2",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAsYAAAHWCAYAAAB0Vk+zAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABC1klEQVR4nO3de1TUdeL/8deAApKCEgpiKphmXgE1icq0DVNz3drqaNZ6W9MuumpUm2aJZnnL1NYsy1L7teWtLesczS4W61qUhVLeE8O0ErwliBokvH9/GPN1BExGmBnePh/ncDbe8/7MvOfjOL4+r/3MZxzGGCMAAADgIufn7QUAAAAAvoBgDAAAABCMAQAAgNMIxgAAAADBGAAAADiNYAwAAAAQjAEAAIDTCMYAAAAAwRgAAAA4jWAM4KIwePBgRUdHu4zl5+frnnvuUWRkpBwOh8aMGeO19VUVh8OhiRMnVvnjpKamyuFwKDU11TnWrVs3tW3btsofW5L27Nkjh8OhxYsXe+TxANiJYAzAZ0ycOFEOh0OHDh0q8/a2bduqW7dulfZ4U6ZM0eLFi3X//ffr9ddf14ABAyrtvqtCdHS0HA6HHA6H/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6tDhw4aP368cnNz9eOPP2r27NnO+z7T5MmTFRAQoIcfflgFBQXnbMh/+eUX3Xzzzerbt6/69++v5cuX6/7771dAQID+/ve/V+g5ns/azvTxxx+rV69eatasmSZOnKiTJ09q7ty5uvbaa7Vx48ZSH8bs27evYmJiNHXqVG3cuFGvvPKKGjRooOnTp1donQCqMQMAPiIlJcVIMgcPHizz9jZt2piuXbs6f//000+NJNOqVStTUFDgHH/uueeMJLN582bn2KBBg0zTpk1d7q9p06amd+/eLmNz5swxksy///1v51hhYaFJTEw0tWvXNnl5ecYYY7KysowkExISYg4cOFDm8xg+fLhz7NSpU+ayyy4zDofDTJs2zTn+yy+/mFq1aplBgwb94f4pa71nmj17tpFk3n33XeeYJJOSkuL8PTQ01IwYMeKcj9O7d+9S+8qcsb+bNWtmTpw4UeZtn376qXOsa9euRpJ59tlnnWMFBQUmLi7ONGjQwBQWFhpjjFm0aJGRZLKysv7wPstbW8mfx6JFi5xjJY9z+PBh59g333xj/Pz8zMCBA51jJX9ef//7313u869//au59NJLz7mvANiFUykAVHtDhgxxaS27dOkiSfr+++8rfF+rV69WZGSk+vfv7xyrWbOmRo0apfz8fP33v/91mX/77berfv36Zd7XPffc4/xvf39/derUScYYDR061Dlet25dtWzZ0q21nq2kPT127Fi5c+rWrasvv/xSP//8s9uPM2jQINWqVeu85taoUUP33nuv8/eAgADde++9OnDggNLT091ewx/Zv3+/MjIyNHjwYJcWv3379urevbtWr15dapv77rvP5fcuXbro8OHDysvLq7J1AvAtBGMA1YrD4Sg11qRJE5ff69WrJ/3+f+NX1A8//KAWLVo4r6xQolWrVs7bzxQTE1PufZ29rtDQUAUFBZW64kZoaKhbaz1bfn6+JKlOnTrlzpkxY4a2bNmixo0bq3Pnzpo4cWKFQ/m5nvPZoqKidMkll7iMXXHFFdLv5wVXlZI/p5YtW5a6rVWrVjp06JCOHz/uMl6ZryMA1RPBGIDPKLmqwMmTJ8u8/cSJE2VeeaC8y3N54mqU52pOy1pXVa615LJozZs3L3dO37599f3332vu3LmKiorSM888ozZt2uj9998/78c537b4fJV1sCNJRUVFlfo4f8SbryMAvoFgDMBnNG3aVJK0c+fOUredOHFC+/btc86pyjXs2rVLxcXFLuM7duxwWaOvyc/P1zvvvKPGjRs72+3yNGzYUA888IBWrlyprKwsXXrppXr66aedt5cXVN3x888/l2pmv/vuO+n36zLrjGb26NGjLvPObucrsrZzvZZ27Nih8PDwUk02ABCMAfiMG2+8UQEBAXrxxRdLBdOXX35Zp06dUq9evap0DTfffLOys7O1bNky59ipU6c0d+5c1a5dW127dq3Sx3fHyZMnNWDAAB05ckTjx48/ZwObm5vrMtagQQNFRUWpoKDAOXbJJZeUmueuU6dO6aWXXnL+XlhYqJdeekn169dXx44dJUmXX365JGndunUua3355ZdL3d/5rq1hw4aKi4vTa6+95hK4t2zZog8//FA333zzBT83APbhcm0AfEaDBg00YcIEPf7447r++uv1l7/8RcHBwfr888+1ZMkS3XTTTerTp0+VrmH48OF66aWXNHjwYKWnpys6OlpvvfWWPvvsM82ZM+ec5+96wk8//aR///vf0u8t8bZt25zffPfQQw+5fNDtbMeOHdNll12mO+64Q7Gxsapdu7Y+/vhjffXVVy7XUu7YsaOWLVum5ORkXXXVVapdu7bb+z0qKkrTp0/Xnj17dMUVV2jZsmXKyMjQyy+/7PzSlTZt2ujqq6/WuHHjdOTIEYWFhWnp0qU6depUqfuryNqeeeYZ9erVS4mJiRo6dKjzcm2hoaEu13YGgBIEYwA+Zfz48YqOjtbzzz+vJ598UqdOnVJMTIwmTZqkRx99tNSH4ipbrVq1lJqaqrFjx+q1115TXl6eWrZsqUWLFmnw4MFV+tjnIyMjQwMGDJDD4VCdOnXUuHFj9enTR/fcc486d+58zm2Dg4P1wAMP6MMPP9Tbb7+t4uJiNW/eXC+88ILLt+U98MADysjI0KJFizR79mw1bdrU7WBcr149vfbaa/rHP/6hBQsWKCIiQs8//7yGDRvmMu+NN97Qvffeq2nTpqlu3boaOnSobrjhBnXv3t1lXkXWlpSUpDVr1iglJUUTJkxQzZo11bVrV02fPr1CHyAEcPFwGD5VAAAAAHCOMQAAACCCMQAAAHAawRgAAADwtWC8bt069enTR1FRUXI
|
||
|
"text/plain": [
|
||
|
"<Figure size 800x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"from scipy.stats import uniform # Import scipys uniform\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"\n",
|
||
|
"# Define the distribution parameters to be plotted\n",
|
||
|
"sigma = 1\n",
|
||
|
"mu = 0\n",
|
||
|
"x = np.linspace(-0.5, 1.5, 1000)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"# plot the distributions\n",
|
||
|
"fig, ax = plt.subplots(figsize=(8, 5))\n",
|
||
|
"\n",
|
||
|
"dist = uniform(mu, sigma)\n",
|
||
|
"\n",
|
||
|
"plt.plot(x, dist.pdf(x), c='black', label=r'$\\mu=%i,\\ \\sigma=%i$' % (mu, sigma))\n",
|
||
|
"\n",
|
||
|
"plt.xlim(-0.5, 1.5)\n",
|
||
|
"plt.ylim(0, 1.2)\n",
|
||
|
"\n",
|
||
|
"plt.xlabel('$x$')\n",
|
||
|
"plt.ylabel(r'$p(x|\\mu, \\sigma)$')\n",
|
||
|
"plt.title('Uniform Distribution')\n",
|
||
|
"\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"id": "2431e6fc-1efb-40e1-8865-42b1be95f95e",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAsYAAAHWCAYAAAB0Vk+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qMGDB2vx4sV64IEH5O7urn/84x9FjnHz5s267rrrVL9+fY0dO1bVqlXT4sWLdfPNN+uDDz7QX//6V+nPAGX69Om655571KlTJ2VmZmrdunVav369evbsWei+b7nlFtWqVUsPP/ywBg8erD59+qh69epOff72t7+pWbNmmjZtmuNif8899+jNN9/UbbfdpkceeUTfffedpk+frq1bt+qjjz5y2n7Xrl0aMmSI7rvvPv3973/XzJkz1b9/f8XHx2v8+PF68MEHHfM5cOBAbd++Xa6uRecf9uzZo6VLl+pvf/ubGjVqpPT0dL366qvq3r27tmzZosDAwCK3LanffvtNvXr10i233KKBAwfq/fff12OPPaaQkBD17t270G0mTJig5s2b67XXXnOUJjRp0kT6s5Y3JiZGHTt21PTp05Wenq4XXnhB33zzjTZs2OCUYT5z5oyio6PVpUsXzZw5U97e3o6fXe45WVx33nmnxo8fry+++ELDhw8vtM/mzZvVr18/tWnTRlOmTJGHh4d27dqlb775RpLUsmVLTZkyRRMnTtS9996rrl27SpI6d+7s2MfRo0fVu3dv3X777fr73/8uf3//C47rqaeekouLix577DEdOnRIs2fPVlRUlFJTUx2Z7UtxKWM7l2VZGjBggL766ivdfffdCg0N1eeff64xY8bol19+0fPPP+/Uf/Xq1frwww/14IMPqkaNGvrXv/6lW2+9Vfv379dVV111yeMEKhwLQJm77777LEmWJMvV1dW67bbbrGPHjl10uzfeeMOSZLm7u1s9evSwnnjiCevrr7+2cnNzC/Q9efKk0+ucnByrdevW1vXXX+/ULsny8PCw9u7d62h79dVXLUlWQECAlZmZ6WgfN26cJcmpb/fu3S1J1nPPPedoO3XqlBUaGmrVrVvXysnJsSzLsvbu3WtJsubPn+/od8MNN1ghISHWH3/84WjLy8uzOnfubDVr1szR1rZtW6tv374XnZ/z5b/ns88+69QeFxdnSbIGDx7s1J6ammpJsu655x6n9kcffdSSZK1cudLRFhQUZEmyvv32W0fb559/bkmyvLy8rJ9++snRnj+fX3311QXH+8cffxT4Xe7du9fy8PCwpkyZctHjlWSNGDGi0J8tWbKkwBjyf3f//ve/HW2nTp2yAgICrFtvvdVpDOf/7ubPn29Jsr7//ntHW05OjlW3bl2rdevW1u+//+5o/+STTyxJ1sSJEx1tQ4cOtSRZY8eOLfQ4LuecLExh4z1fzZo1rbCwMMfr/PMk3/PPP29Jsg4fPlzkPr7//vsCc5Uvf77j4+ML/Vn37t0dr7/66itLklW/fn2n4128eLElyXrhhRccbUFBQdbQoUMvus8LjW3o0KFWUFCQ4/XSpUstSdaTTz7p1O+2226zXFxcrF27djna8tekc9s2btxoSbJefPHFImYKqBwopQBsMHr0aK1YsUJvvvmmevfurdzcXOXk5Fx0u3/84x9KSEhQZGSkVq9eralTp6pr165q1qyZvv32W6e+52aTfvvtN2VkZKhr165av359gf3ecMMNTn9GDQ8PlyTdeuutqlGjRoH2PXv2OG1fpUoV3XfffY7X7u7uuu+++3To0CGlpKQUeizHjh3TypUrNXDgQJ04cUJHjhzRkSNHdPToUUVHR2vnzp2OP7/XqlVLmzdv1s6dOy86R8Vx//33O71evny5JCk2Ntap/ZFHHpEkffrpp07trVq1UkREhON1/vxcf/31atiwYYH28+ftfB4eHo6Mcm5uro4ePer4c31hv7fSUL16df397393vHZ3d1enTp0uOtbCrFu3Toc
|
||
|
"text/plain": [
|
||
|
"<Figure size 800x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Parameters\n",
|
||
|
"mu = 0\n",
|
||
|
"sigma = 1\n",
|
||
|
"\n",
|
||
|
"# Get a 3 random samples\n",
|
||
|
"rand = np.random.default_rng(5000)\n",
|
||
|
"uniform_samples = rand.uniform(mu, sigma, 3)\n",
|
||
|
"\n",
|
||
|
"# Linespace\n",
|
||
|
"x = np.linspace(-0.5, 2, 1000)\n",
|
||
|
"\n",
|
||
|
"# Get uniform from linespace\n",
|
||
|
"dist = uniform(mu, sigma)\n",
|
||
|
"\n",
|
||
|
"# Plot Uniform\n",
|
||
|
"fig, ax = plt.subplots(figsize=(8, 5))\n",
|
||
|
"plt.plot(x, dist.pdf(x), c='black', label=r'$\\mu=%i,\\ \\sigma=%i$' % (mu, sigma))\n",
|
||
|
"\n",
|
||
|
"# Plot samples\n",
|
||
|
"step = 0.1\n",
|
||
|
"for u in uniform_samples:\n",
|
||
|
" u = np.round(u, decimals=2)\n",
|
||
|
" plt.axvline(u, color='r')\n",
|
||
|
" plt.text(u, .5+step, u, color='g')\n",
|
||
|
" step += 0.1\n",
|
||
|
"\n",
|
||
|
"# Cosmetics\n",
|
||
|
"plt.xlim(-0.5, 1.5)\n",
|
||
|
"plt.ylim(0, 1.2)\n",
|
||
|
"\n",
|
||
|
"plt.xlabel('$x$')\n",
|
||
|
"plt.ylabel(r'$p(x|\\mu, \\sigma)$')\n",
|
||
|
"plt.title('3 Samples from a Uniform Distribution')\n",
|
||
|
"\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"id": "91d9bce6-8223-455f-be61-5a932ac73b44",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArsAAAHWCAYAAAB34UGbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB4sElEQVR4nO3dd1hT5+MF8BNA9lBEcQuKCwVRVEStolJxa1tX3ajgHkWtxb1x4F4ozrqrraPaWhX3nrililsERGXLSu7vj6/kJwUVMPCG5HyeJ4/kcm9ycpvCyeW975VJkiSBiIiIiEgD6YgOQERERESUV1h2iYiIiEhjsewSERER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w5swZzJgxA9988w0qVaqEc+fOZVg3fTwiPhx5i4mJwTfffJPl0dDmzZtn+NOmi4sLAOCHH36AmZlZpuWPHj3KsL2enh4GDhyovK+vr4+BAwciMjISV69ezfK1vH37FseOHUOXLl0QFxeHqKgoREVF4c2bN/Dw8MCDBw/w8uVL4MOY2zt37uDBgwdf3Ec5MWjQoAz3//rrLwDIdERr9OjRAJDpqLi9vT1cXV2V99P3T7NmzVCuXLlMy/+73/7LwMAAOjr/+5Esl8vx5s0b5Z/QP3cUOysTJ0787NFduVyOw4cPo2PHjqhQoYJyecmSJdG9e3ecOXMGsbGxGbbx8vKCrq5upscyNTXNcOS7SpUqKFy4MKpVq6Z87fjEfvj4fZqamoo3b97Azs4OhQsXzvFrzi5TU9PPzsqQPsZ73759Xzwa/yk
|
||
|
"text/plain": [
|
||
|
"<Figure size 800x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Import scipys norm\n",
|
||
|
"from scipy.stats import norm \n",
|
||
|
"\n",
|
||
|
"#Parameters\n",
|
||
|
"mu = 0\n",
|
||
|
"sigma = 1\n",
|
||
|
"\n",
|
||
|
"# Get a 3 random samples\n",
|
||
|
"rand = np.random.default_rng(5000)\n",
|
||
|
"uniform_samples = rand.normal(mu, sigma, 3)\n",
|
||
|
"\n",
|
||
|
"# Linespace\n",
|
||
|
"x = np.linspace(-4, 4, 1000)\n",
|
||
|
"\n",
|
||
|
"# Get uniform from linespace\n",
|
||
|
"dist = norm(mu, sigma)\n",
|
||
|
"\n",
|
||
|
"# Plot Uniform\n",
|
||
|
"fig, ax = plt.subplots(figsize=(8, 5))\n",
|
||
|
"plt.plot(x, dist.pdf(x), c='black', label=r'$\\mu=%i,\\ \\sigma=%i$' % (mu, sigma))\n",
|
||
|
"\n",
|
||
|
"# Plot samples\n",
|
||
|
"step = 0.1\n",
|
||
|
"for u in uniform_samples:\n",
|
||
|
" u = np.round(u, decimals=2)\n",
|
||
|
" plt.axvline(u, color='r')\n",
|
||
|
" plt.text(u, .1+step, u, color='g')\n",
|
||
|
" step += 0.1\n",
|
||
|
"\n",
|
||
|
"# Cosmetics\n",
|
||
|
"plt.xlim(-4, 4)\n",
|
||
|
"plt.ylim(0, .5)\n",
|
||
|
"\n",
|
||
|
"plt.xlabel('$x$')\n",
|
||
|
"plt.ylabel(r'$p(x|\\mu, \\sigma)$')\n",
|
||
|
"plt.title('3 Samples from a Normal Distribution')\n",
|
||
|
"\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"id": "b9b53ef7-374c-44f3-b1e2-7bf95e77b535",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAdoAAAGyCAYAAABDQwWYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABlfklEQVR4nO3dd1xV9eM/8NdlDwVElKEoLsgVKCjhRCXBAZJmophbcpSaC7HUHIkrK8vUzJULtY8DF2YITgJBESeI4QZceRFU5vv3xzfvrxuggNx7gPt6Ph73UZz7vue8Dld4cc49QyaEECAiIiKV0JI6ABERUVXGoiUiIlIhFi0REZEKsWiJiIhUiEVLRESkQixaIiIiFWLREhERqRCLloiISIVYtERERCrEoiUiIlIhlRbtiRMn4O3tDRsbG8hkMuzdu/eNr4mMjETr1q2hr6+Pxo0bY+PGjYXGrFy5EnZ2djAwMICrqytiYmJUtAZERERvR6VFm5WVBUdHR6xcubJE41NSUtC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5agYcOG+Pbbb5Gbmyt1PFIDFi2pXW5uLpYvXw4HBwfs3bsXy5cvR1JSEoYNG8aDnKjKMjc3x+LFi5GcnIx+/fph6tSpcHR0RHh4uNTRSMVYtKRWx44dg6OjI6ZNm4ahQ4fi+vXrmDhxIvT19aWORqQWderUwZo1a3Du3DlYWFjAw8MDH330EW7fvi11NFIRFi2pxZ07dzBgwAB069YN5ubmiIuLww8//IAaNWpIHY1IEo6Ojjh+/Di2bNmCkydPomn
|
||
|
"text/plain": [
|
||
|
"<Figure size 500x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"circle = plt.Circle((0, 0), 1, color='black', fill=False)\n",
|
||
|
"fig, ax = plt.subplots(figsize=(5,5))\n",
|
||
|
"ax.add_patch(circle)\n",
|
||
|
"ax.plot(np.linspace(0,1), np.zeros(50), color='black')\n",
|
||
|
"ax.text(0.5, 0.05, \"$r = 1$\")\n",
|
||
|
"\n",
|
||
|
"plt.xlim(-1, 1)\n",
|
||
|
"plt.ylim(-1, 1)\n",
|
||
|
"\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "8a9aa971-bcc4-49e9-844a-a8e23be0be4d",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"source": [
|
||
|
"$$\\frac{A_{circle}}{A_{square}} = \\frac{\\pi}{4}$$\n",
|
||
|
"\n",
|
||
|
"$$\\pi = 4 \\cdot \\frac{A_{circle}}{A_{square}}$$"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"id": "86b877fd-9713-49a8-bd32-b2b2a4cf6917",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAdoAAAGyCAYAAABDQwWYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACWmElEQVR4nOzdd1gU1xoG8Hd2l16lSFEULGAHBUSsWLGBRqOgxILtWmI0dqwxdk1M7C323nuwoVgRBRXsiIKKVEF62zL3D3UTAijI7s4u+/3us8/NzM7MeReVb2fmzDkMy7IsCCGEECIXPK4DEEIIIZUZFVpCCCFEjqjQEkIIIXJEhZYQQgiRIyq0hBBCiBxRoSWEEELkiAotIYQQIkdUaAkhhBA5okJLCCGEyBEVWkIIIUSO5Fpor127Bi8vL1hbW4NhGJw4ceKr+wQHB6NZs2bQ0tJCnTp1sGPHjmLbrFu3Dra2ttDW1oabmxvu3Lkjp09ACCGEVIxcC21OTg4cHR2xbt26Mm0fExODHj16oH379njw4AEmTpyIESNG4Pz589JtDh48iEmTJmHevHm4d+8eHB0d4enpieTkZDl+EkIIIeTbMIqaVIBhGBw/fhy9e/cudZvp06fj7NmzePTokXSdr68v0tPTce7cOQCAm5sbXF1dsXbtWgCARCKBjY0Nxo8fjxkzZijgkxBCCCFlJ+A6wL+FhISgU6dORdZ5enpi4sSJAIDCwkKEh4cjICBA+j6Px0OnTp0QEhJS6nELCgpQUFAgXZZIJEhLS4OpqSkYhpHLZyGEEKL8WJZFVlYWrK2twePJ5yKvUhXaxMREWFhYFFlnYWGBzMxM5OXl4cOHDxCLxSVu8+zZs1KPu2TJEsyfP19uuQkhhKi2t2/fonr16nI5tlIVWnkJCAjApEmTpMsZGRmoUaMG3r59C0NDQ06zEZKfn4+YmBhER0cXe71//77IthoaGrC0tISFhQUsLS1hZWUFc3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R0drmMSjllbW2PSpEkIDw/HkydPMH78eFy6dAnu7u5o1qwZtmzZgobGDVHDqAb4zMcvYwwY+DXx4zo6USF06VhFLx0vvLYQc67MAT79w9/qvRX+TdV7dCyxWIzz589jw4YNOHv2LAwMDDB48GCMHj0aDRs25DoeUREl/T36buh3+ND0A7KYLLS3bY+ANgEQ8JRqBFvyjegerZyoeqFNzE6E1e9WRdZp8bWQMzMHfJ76XQJNSUnBtm3bsGnTJsTExMDJyQljx47FgAEDoK+vz3W8b5KYnYjknGTUrlIbepo0shRXYmNjsXnzZmzduhXJyclo164dxo4di969e1OHuUqC7tGSEqXnpxdbVyAuQIG4oMTtK6uoqCiMHDkS1atXx7x589CmTRuEhITg3r17GDlypMoW2dWhq1FtZTU4bnRE7dW18TDpIdeR1JatrS0WL16Mt2/fYv/+/WBZFj4+PrC1tcXy5cuRmZnJdUSiAqjQqqBaVWqhrkld6T0jPsNHu5rtoKuhHiPghIeHo1+/fqhXrx7OnDmDX3/9Fe/evcPOnTvRokULlR5Q4tn7Z5h4biIkrAQA8D73PQYdH8R1LLWnqakJX19fXL16FQ8fPkSPHj0wZ84c1KhRAzNnziw2dSch/0aFVgVp8jVxechl9LTvCQdTBwxoNADHfY5zHUuuWJbF5cuX0blzZ7i4uOD+/fvYuHEjYmJiMH369EozqERseixY/HM3R8yK8erDK04zkaIaNWqELVu2ICYmBiNHjsSaNWtQs2ZNjB07FjExMVzHI0qI7tGq4D1adSKRSHDixAksXboUd+/eRdOmTTFjxgz07du3Uj6SE5cZhzqr66BQXAgWLPgMH+1t2+Pi4ItcRyOl+PDhA9avX48///wTHz58gI+PD6ZPn44mTZpwHY2UAd2jJWqLZVkcO3Y
|
||
|
"text/plain": [
|
||
|
"<Figure size 500x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Get Uniform x, y samples\n",
|
||
|
"rand = np.random.default_rng(42) # Set fixed Value\n",
|
||
|
"x_rand = rand.uniform(-1, 1, 100)\n",
|
||
|
"y_rand = rand.uniform(-1, 1, 100)\n",
|
||
|
"\n",
|
||
|
"# Plot \n",
|
||
|
"circle = plt.Circle((0, 0), 1, color='black', fill=False)\n",
|
||
|
"fig, ax = plt.subplots(figsize=(5,5))\n",
|
||
|
"ax.add_patch(circle)\n",
|
||
|
"ax.plot(np.linspace(0,1), np.zeros(50), color='black')\n",
|
||
|
"ax.text(0.5, 0.05, \"$r = 1$\")\n",
|
||
|
"plt.xlim(-1, 1)\n",
|
||
|
"plt.ylim(-1, 1)\n",
|
||
|
"\n",
|
||
|
"# Plot samples as small circles\n",
|
||
|
"for x, y in zip(x_rand, y_rand):\n",
|
||
|
" c = plt.Circle((x,y), 0.01, color='green')\n",
|
||
|
" ax.add_patch(c)\n",
|
||
|
"\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "2d6d0132-647a-4f83-82c1-e97e79e68a37",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"source": [
|
||
|
"Parametrisierte Kreisgleichung: $$x^2+y^2=r,\\quad r=1$$"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"id": "d4416d57-35e6-49c3-8367-592e9814ac7a",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# reserve two arrays\n",
|
||
|
"circle_coords = []\n",
|
||
|
"square_coords = []\n",
|
||
|
"\n",
|
||
|
"for x,y in zip(x_rand, y_rand):\n",
|
||
|
" # calculate distance from origin\n",
|
||
|
" dist_from_origin = x**2 + y**2\n",
|
||
|
"\n",
|
||
|
" # if distance smaller or equal than 1, the point is in the circle\n",
|
||
|
" if dist_from_origin <= 1:\n",
|
||
|
" circle_coords.append((x,y))\n",
|
||
|
"\n",
|
||
|
" # by definition is every point in the square\n",
|
||
|
" square_coords.append((x,y))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"id": "71d3f85c-b85f-488f-8369-c81c5d3d6bf8",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Pi = 3.12\n",
|
||
|
"Difference to real Value 0.02159265358979301\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"pi = 4 * len(circle_coords) / len(square_coords)\n",
|
||
|
"print(f\"Pi = {pi}\")\n",
|
||
|
"print(f\"Difference to real Value {np.pi - pi}\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"id": "31743c3a-4ebe-46ba-a383-0dfdf98d8b37",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAdoAAAGyCAYAAABDQwWYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACUHklEQVR4nOzdd3xN9x/H8dcdWTJFyLBXYq+IiBmj9mq1NdJS86d0KFpUUdVStDq0RdVqba2tqCJmBDFix4idgUgiIskd398f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9oWGKp3MMiIiIvjyyy/5448/8PT0ZOjQofTv3z9f3Hu9+OcZyrSvgprMb0s9Gi7YV8Pv/lGlo0kPnDhxgu+++45ff/0VBwcHBg8ezPvvv5/jSU0k6yLPaKVs2drC9u2ZM5H4+WU+z7d6tdKpzEsIwfbt23nppZeoW7cuR44cYdasWURHRzNy5Mh8UWQBEg5fMhVZAC0GvNMuKppJyqpatWrMmTOH6OhoBgwYwIwZMyhdujSDBw8mOjpa6XiSFZKFNo8qUSLzAfozZ+C33zIfN8iPjEYjq1atIjAwkBYtWnD79m2WL1/O2bNnGThw4CPPPOZ1xVtXIw07jGQO86hDwzn3QKVjSdnw8fFh2rRpXLlyhbFjx7Jy5UoqVqxISEiIadIJSUIWWslaCSFYtWoV1apVo2vXrjg6OrJ582YiIiJ4/fXX8+3gEt4BJTg+YTUJKg+MqDjtXJ+SO35TOpb0BIULF2bMmDFcvnyZb7/9lr1791KzZk26dOnCyZM
|
||
|
"text/plain": [
|
||
|
"<Figure size 500x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Plot \n",
|
||
|
"circle = plt.Circle((0, 0), 1, color='black', fill=False)\n",
|
||
|
"fig, ax = plt.subplots(figsize=(5,5))\n",
|
||
|
"ax.add_patch(circle)\n",
|
||
|
"ax.plot(np.linspace(0,1), np.zeros(50), color='black')\n",
|
||
|
"ax.text(0.5, 0.05, \"$r = 1$\")\n",
|
||
|
"plt.xlim(-1, 1)\n",
|
||
|
"plt.ylim(-1, 1)\n",
|
||
|
"\n",
|
||
|
"# Plot samples not in the circle\n",
|
||
|
"for coord in square_coords:\n",
|
||
|
" c = plt.Circle(coord, 0.01, color='blue')\n",
|
||
|
" ax.add_patch(c)\n",
|
||
|
"\n",
|
||
|
"# Plot samples in the circle\n",
|
||
|
"for coord in circle_coords:\n",
|
||
|
" c = plt.Circle(coord, 0.01, color='red')\n",
|
||
|
" ax.add_patch(c)\n",
|
||
|
"\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"id": "bd4c6bab-20dd-4f9c-9966-96b7988f4afa",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Pi = 3.14178\n",
|
||
|
"Difference to real Value -0.00018734641020667908\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Get Uniform x, y samples\n",
|
||
|
"sample_size = 1_000_000\n",
|
||
|
"rand = np.random.default_rng(42) # Set fixed Value\n",
|
||
|
"x_rand = rand.uniform(-1, 1, sample_size)\n",
|
||
|
"y_rand = rand.uniform(-1, 1, sample_size)\n",
|
||
|
"\n",
|
||
|
"# reserve two arrays\n",
|
||
|
"in_circle = 0\n",
|
||
|
"in_square = 0\n",
|
||
|
"\n",
|
||
|
"for x,y in zip(x_rand, y_rand):\n",
|
||
|
" # calculate distance from origin\n",
|
||
|
" dist_from_origin = x**2 + y**2\n",
|
||
|
"\n",
|
||
|
" # if distance smaller or equal than 1, the point is in the circle\n",
|
||
|
" if dist_from_origin <= 1:\n",
|
||
|
" in_circle += 1\n",
|
||
|
"\n",
|
||
|
" # by definition is every point in the square\n",
|
||
|
" in_square += 1\n",
|
||
|
"\n",
|
||
|
"pi = 4 * in_circle / in_square\n",
|
||
|
"print(f\"Pi = {pi}\")\n",
|
||
|
"print(f\"Difference to real Value {np.pi - pi}\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "618923ef-21b8-4280-abc4-1f1a8a6212a7",
|
||
|
"metadata": {
|
||
|
"editable": true,
|
||
|
"slideshow": {
|
||
|
"slide_type": ""
|
||
|
},
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"sims = \n",
|
||
|
"\n",
|
||
|
"excercise_1 = np.random.uniform(,,sims)\n",
|
||
|
"excercise_2 = np.random.uniform(,,sims)\n",
|
||
|
"\n",
|
||
|
"duration = excercise_1 + excercise_2\n",
|
||
|
"chance = float(np.round((duration > ).sum()/sims, decimals=2))\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(5,2.5))\n",
|
||
|
"plt.hist(duration, density=True)\n",
|
||
|
"plt.axvline(, color='r')\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"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.12.7"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|