Solution 4

parent 0d9ec61d
......@@ -12,7 +12,7 @@
"metadata": {},
"source": [
"## Asking the maths library\n",
"My computer tells me that $\\pi$ is approximatively"
"My computer tells me that $\\pi$ is *approximatively*"
]
},
{
......@@ -37,13 +37,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Buffalo's needle\n",
"## Buffon's needle\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": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
......@@ -52,7 +52,7 @@
"3.128911138923655"
]
},
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
......@@ -63,21 +63,21 @@
"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)\n"
"2/(sum((x+np.sin(theta))>1)/N)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.3 Using a surface fraction argument"
"## Using a surface fraction argument"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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:"
]
},
{
......@@ -99,7 +99,7 @@
}
],
"source": [
"%matplotlib inline\n",
"%matplotlib inline \n",
"import matplotlib.pyplot as plt\n",
"\n",
"np.random.seed(seed=42)\n",
......
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