From 9cd6992041fa849ffd223883c491350d9953086e Mon Sep 17 00:00:00 2001 From: 4009040953332c8dc839a21614bfec10 <4009040953332c8dc839a21614bfec10@app-learninglab.inria.fr> Date: Sat, 25 Nov 2023 12:15:45 +0000 Subject: [PATCH] Modifier N --- module2/exo1/toy_notebook_fr.ipynb | 49 ++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb index 0bbbe37..bb4f3b5 100644 --- a/module2/exo1/toy_notebook_fr.ipynb +++ b/module2/exo1/toy_notebook_fr.ipynb @@ -1,5 +1,49 @@ { - "cells": [], + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3.141592653589793\n" + ] + } + ], + "source": [ + "from math import *\n", + "print(pi)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3.128030279333104" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import numpy as np\n", + "np.random.seed(seed=42)\n", + "N = 50000\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": { "kernelspec": { "display_name": "Python 3", @@ -16,10 +60,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.6.4" } }, "nbformat": 4, "nbformat_minor": 2 } - -- 2.18.1