Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ce14f10f5bc5e484777f1060f8856ea9
mooc-rr
Commits
d87be417
Commit
d87be417
authored
Jun 07, 2022
by
ce14f10f5bc5e484777f1060f8856ea9
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try 3 I think I have it now
parent
767aec72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
7 deletions
+27
-7
toy_notebook_en.ipynb
module2/exo1/toy_notebook_en.ipynb
+27
-7
No files found.
module2/exo1/toy_notebook_en.ipynb
View file @
d87be417
{
{
"cells": [
"cells": [
{
{
"cell_type": "code",
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"metadata": {},
"outputs": [],
"source": [
"source": [
"# On the computation of $\\pi$\n"
"# On the computation of $\\pi$\n"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"metadata": {},
"outputs": [],
"source": [
"source": [
"## Asking the maths library\n",
"## Asking the maths library\n",
"My computer tells me that $\\pi$ is approximately"
"My computer tells me that $\\pi$ is approximately"
]
]
},
},
{
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {},
"outputs": [],
"source": [
"source": [
"from math import *\n",
"from math import *\n",
"print(pi)"
"print(pi)"
]
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##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": null,
"metadata": {},
"outputs": [],
"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)"
]
}
}
],
],
"metadata": {
"metadata": {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment