From f843255a4fd535058b7d338438c25cc715d0aa82 Mon Sep 17 00:00:00 2001 From: Kees van Kempen Date: Tue, 18 Oct 2022 18:25:51 +0200 Subject: [PATCH] 06: Do minor speed improvements --- Exercise sheet 6/exercise_sheet_06.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Exercise sheet 6/exercise_sheet_06.ipynb b/Exercise sheet 6/exercise_sheet_06.ipynb index d04ff24..8664b39 100644 --- a/Exercise sheet 6/exercise_sheet_06.ipynb +++ b/Exercise sheet 6/exercise_sheet_06.ipynb @@ -294,8 +294,8 @@ " s_i_n = -state[site]@nhat\n", " for nbr in neighboring_sites(site,w):\n", " s_j_n = state[nbr]@nhat\n", - " p_add = 1 - np.exp(-2*beta*s_i_n*s_j_n)\n", - " if np.sign(s_i_n) == np.sign(s_j_n) and rng.uniform() < p_add:\n", + " one_minus_p_add = np.exp(-2*beta*s_i_n*s_j_n)\n", + " if np.sign(s_i_n) == np.sign(s_j_n) and rng.uniform() > one_minus_p_add:\n", " state[nbr] -= 2*s_j_n*nhat\n", " unvisited.appendleft(nbr)\n", " cluster_size += 1\n", @@ -311,7 +311,7 @@ }, { "cell_type": "code", - "execution_count": 107, + "execution_count": 109, "id": "3f810041", "metadata": { "deletable": false, @@ -342,7 +342,7 @@ }, { "cell_type": "code", - "execution_count": 108, + "execution_count": 110, "id": "bde560e4", "metadata": { "deletable": false,