(Useless) Edit metadata

parent f5c0c658
...@@ -9,17 +9,21 @@ ...@@ -9,17 +9,21 @@
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {
"hideCode": false
},
"source": [ "source": [
"## Asking the maths library\n", "## Asking the maths library\n",
"\n",
"My computer tells me that π is *approximatively*" "My computer tells me that π is *approximatively*"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": {}, "metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
...@@ -36,17 +40,21 @@ ...@@ -36,17 +40,21 @@
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {
"hidePrompt": false
},
"source": [ "source": [
"## Buffon's needle\n", "## Buffon's needle\n",
"\n",
"Applying the method of [Buffon’s needle](https://en.wikipedia.org/wiki/Buffon%27s_needle_problem), we get the **approximation**" "Applying the method of [Buffon’s needle](https://en.wikipedia.org/wiki/Buffon%27s_needle_problem), we get the **approximation**"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": {}, "metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [ "outputs": [
{ {
"data": { "data": {
...@@ -70,10 +78,11 @@ ...@@ -70,10 +78,11 @@
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {
"hideCode": false
},
"source": [ "source": [
"## Using a surface fraction argument\n", "## Using a surface fraction argument\n",
"\n",
"A method that is easier to understand and does not make use of the sin function is based on the fact that if $X \\sim U(0, 1)$ and $Y \\sim U(0, 1)$, then $P[X^2 + Y^2 \\leq 1] = \\pi/4$ (see [\"Monte Carlo method\" on Wikipedia](https://en.wikipedia.org/wiki/Monte_Carlo_method)). The following code uses this approach:" "A method that is easier to understand and does not make use of the sin function is based on the fact that if $X \\sim U(0, 1)$ and $Y \\sim U(0, 1)$, then $P[X^2 + Y^2 \\leq 1] = \\pi/4$ (see [\"Monte Carlo method\" on Wikipedia](https://en.wikipedia.org/wiki/Monte_Carlo_method)). The following code uses this approach:"
] ]
}, },
...@@ -98,11 +107,12 @@ ...@@ -98,11 +107,12 @@
"source": [ "source": [
"%matplotlib inline\n", "%matplotlib inline\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"\n",
"np.random.seed(seed=42)\n", "np.random.seed(seed=42)\n",
"N = 1000\n", "N = 1000\n",
"x = np.random.uniform(size=N, low=0, high=1)\n", "x = np.random.uniform(size=N, low=0, high=1)\n",
"y = np.random.uniform(size=N, low=0, high=1)\n", "y = np.random.uniform(size=N, low=0, high=1)\n",
"1\n", "\n",
"accept = (x*x+y*y) <= 1\n", "accept = (x*x+y*y) <= 1\n",
"reject = np.logical_not(accept)\n", "reject = np.logical_not(accept)\n",
"fig, ax = plt.subplots(1)\n", "fig, ax = plt.subplots(1)\n",
...@@ -137,16 +147,10 @@ ...@@ -137,16 +147,10 @@
"source": [ "source": [
"4*np.mean(accept)" "4*np.mean(accept)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
"celltoolbar": "Hide code",
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "Python 3",
"language": "python", "language": "python",
...@@ -162,7 +166,7 @@ ...@@ -162,7 +166,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.4" "version": "3.6.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
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