1.2

parent a8e3a008
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"hideCode": true, "hideCode": false,
"hidePrompt": true "hidePrompt": false
}, },
"source": [ "source": [
"<p style=\"text-align:center\";>__toy\\_notebook\\_fr__</p>\n",
"\n",
"<p style=\"text-align:center\";>March 28, 2019</p>\n", "<p style=\"text-align:center\";>March 28, 2019</p>\n",
"\n", "\n",
"# propos du calcul de $\\pi$\n", "# propos du calcul de $\\pi$\n",
...@@ -20,46 +22,79 @@ ...@@ -20,46 +22,79 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"hideCode": true, "hideCode": false,
"hidePrompt": true "hidePrompt": false
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"from math import * \n", "from math import *\n",
"print(pi)" "print(pi)"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"hideCode": true, "hideCode": false,
"hidePrompt": true "hidePrompt": false
}, },
"source": [ "source": [
"## En utilisant la méthode des aiguilles de Buffon" "## En utilisant la méthode des aiguilles de Buffon"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"Mais calculé avec la méthode des ![aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme __approximation__ :"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"hideCode": true, "hideCode": false,
"hidePrompt": true "hidePrompt": false
}, },
"outputs": [], "outputs": [],
"source": [] "source": [
"import numpy as np\n",
"np.random.seed(seed=42)\n",
"N = 10000\n",
"x = np.random.uniform(size=N, low=0, high=1)\n",
"theta = np.random.uniform(size=N, low=0, high=pi/2)\n",
"2/(sum((x+np.sin(theta))>1)/N)"
]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"hideCode": true, "hideCode": false,
"hidePrompt": true "hideOutput": true,
"hidePrompt": false
}, },
"source": [] "source": [
"## Avec un argument \"fréquentiel\" de surface"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d’appel à la fonction sinus se base sur le fait que si\n",
"\n",
"\n",
"X\u0018U(0, 1)etY\u0018U(0, 1)alorsP[X2+Y2\u00141]=p/4 (voirméthode de Monte Carlo sur Wikipedia). Le code suivant illustre ce fait :"
]
} }
], ],
"metadata": { "metadata": {
"hide_code_all_hidden": true, "hide_code_all_hidden": false,
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "Python 3",
"language": "python", "language": "python",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment