Fixed ambiguity of variable name.

This commit is contained in:
udlbook
2024-02-17 10:07:40 -05:00
parent 566120cc48
commit e11989bd78

View File

@@ -4,7 +4,6 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyNyLnpoXgKN+RGCuTUszCAZ",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -153,9 +152,9 @@
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# TODO: Now construct the matrix A that has the initial distribution constraints\n", "# TODO: Now construct the matrix A that has the initial distribution constraints\n",
"# so that Ap=b where p is the transport plan P vectorized rows first so p = np.flatten(P)\n", "# so that A @ TPFlat=b where TPFlat is the transport plan TP vectorized rows first so TPFlat = np.flatten(TP)\n",
"# Replace this line:\n", "# Replace this line:\n",
"A = np.zeros((20,100))\n" "A = np.zeros((20,100))"
], ],
"metadata": { "metadata": {
"id": "7KrybL96IuNW" "id": "7KrybL96IuNW"
@@ -197,8 +196,8 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"P = np.array(opt.x).reshape(10,10)\n", "TP = np.array(opt.x).reshape(10,10)\n",
"draw_2D_heatmap(P,'Transport plan $\\mathbf{P}$', my_colormap)" "draw_2D_heatmap(TP,'Transport plan $\\mathbf{P}$', my_colormap)"
], ],
"metadata": { "metadata": {
"id": "nZGfkrbRV_D0" "id": "nZGfkrbRV_D0"
@@ -218,7 +217,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"was = np.sum(P * dist_mat)\n", "was = np.sum(TP * dist_mat)\n",
"print(\"Wasserstein distance = \", was)" "print(\"Wasserstein distance = \", was)"
], ],
"metadata": { "metadata": {