From 5152fbfc311914970c60dee5527fe567837fcc74 Mon Sep 17 00:00:00 2001 From: Kees van Kempen Date: Mon, 3 Oct 2022 12:59:06 +0200 Subject: [PATCH] 04: Fix desired mass function --- Exercise sheet 4/exercise_sheet_04.ipynb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Exercise sheet 4/exercise_sheet_04.ipynb b/Exercise sheet 4/exercise_sheet_04.ipynb index 65b9976..95f695b 100644 --- a/Exercise sheet 4/exercise_sheet_04.ipynb +++ b/Exercise sheet 4/exercise_sheet_04.ipynb @@ -393,18 +393,10 @@ " assert x != y\n", " \n", " Q = transition_matrix_Q(graph)\n", - " # TODO: What should pi be?\n", - " # As we have no preference, we'll take pi to be constant for all values.\n", - " pi = np.ones(graph.number_of_nodes())\n", - " #pi = stationary_distributions(Q)[0]\n", + " n = graph.number_of_nodes()\n", + " # We want to sample a uniform mass distribution pi:\n", + " pi = np.ones(n)/n\n", " \n", - " #return np.min(1, pi[y - 1]*Q[x - 1, y - 1]/(pi[x - 1]*Q[y - 1, x - 1]))\n", - " #print(Q[x - 1, y - 1], Q[y - 1, x - 1], Q[x - 1, y - 1]/Q[y - 1, x - 1])\n", - " #A = Q[x-1, y-1]/Q[y-1, x-1]\n", - " #A = Q[y-1, x-1]/Q[x-1, y-1]\n", - " #A = pi[y - 1]*Q[x - 1, y - 1]/( pi[x - 1]*Q[y - 1, x - 1] )\n", - " #A = Q[x, y]/Q[y, x]\n", - " #print(\"<<<\", A, Q, \">>>\")\n", " if Q[x, y] == 0:\n", " return 0\n", " else:\n",