(Useless) Edit metadata

parent f5c0c658
......@@ -9,17 +9,21 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"hideCode": false
},
"source": [
"## Asking the maths library\n",
"\n",
"My computer tells me that π is *approximatively*"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [
{
"name": "stdout",
......@@ -36,17 +40,21 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"hidePrompt": false
},
"source": [
"## 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**"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [
{
"data": {
......@@ -70,10 +78,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"hideCode": false
},
"source": [
"## 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:"
]
},
......@@ -98,11 +107,12 @@
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"\n",
"np.random.seed(seed=42)\n",
"N = 1000\n",
"x = 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",
"reject = np.logical_not(accept)\n",
"fig, ax = plt.subplots(1)\n",
......@@ -137,16 +147,10 @@
"source": [
"4*np.mean(accept)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"celltoolbar": "Hide code",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
......@@ -162,7 +166,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.6.2"
}
},
"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