accept&reject

parent ff37f7be
...@@ -63,16 +63,7 @@ ...@@ -63,16 +63,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -81,12 +72,13 @@ ...@@ -81,12 +72,13 @@
"3.128911138923655" "3.128911138923655"
] ]
}, },
"execution_count": 12, "execution_count": 14,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"import numpy as np\n",
"np.random.seed(seed=42)\n", "np.random.seed(seed=42)\n",
"N = 10000\n", "N = 10000\n",
"x = np.random.uniform(size=N, low=0, high=1)\n", "x = np.random.uniform(size=N, low=0, high=1)\n",
...@@ -111,12 +103,20 @@ ...@@ -111,12 +103,20 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 17,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%matplotlib inline\n", "%matplotlib inline\n",
"import matplotlib.pyplot as plt" "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",
"\n",
"accept = (x*x+y*y) <= 1\n",
"reject = np.logical_not(accept)\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