From 37488148ed84e20b173401744f351e6aa9013dab Mon Sep 17 00:00:00 2001 From: Ricardo Date: Thu, 16 Jun 2022 09:12:35 +0200 Subject: [PATCH] Accommodate feedback and add small section on observed variables Also seed draws --- .../learn/core_notebooks/dimensionality.ipynb | 357 +++++++++--------- 1 file changed, 185 insertions(+), 172 deletions(-) diff --git a/docs/source/learn/core_notebooks/dimensionality.ipynb b/docs/source/learn/core_notebooks/dimensionality.ipynb index 6579f606846..3f09f35be23 100644 --- a/docs/source/learn/core_notebooks/dimensionality.ipynb +++ b/docs/source/learn/core_notebooks/dimensionality.ipynb @@ -35,6 +35,8 @@ }, "outputs": [], "source": [ + "from functools import partial\n", + "\n", "import pymc as pm\n", "import numpy as np\n", "import aesara.tensor as at" @@ -79,6 +81,17 @@ { "cell_type": "code", "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# Just patching the draw function for reproducibility\n", + "rng = np.random.default_rng(seed=sum(map(ord, \"dimensionality\")))\n", + "draw = partial(pm.draw, random_seed=rng)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, "metadata": { "pycharm": { "name": "#%%\n" @@ -88,16 +101,16 @@ { "data": { "text/plain": [ - "(array(-2.62065421), 0)" + "(array(0.80189558), 0)" ] }, - "execution_count": 3, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "normal_draw = pm.draw(normal_dist)\n", + "normal_draw = draw(normal_dist)\n", "normal_draw, normal_draw.ndim" ] }, @@ -114,7 +127,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": { "pycharm": { "name": "#%%\n" @@ -127,7 +140,7 @@ "0" ] }, - "execution_count": 4, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -160,7 +173,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": { "pycharm": { "name": "#%%\n" @@ -170,17 +183,17 @@ { "data": { "text/plain": [ - "array([-0.06684535, 1.29471918, -0.12572735])" + "array([ 0.9434115 , -0.33327414, 0.83636296])" ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normal_dists = pm.math.stack([pm.Normal.dist() for _ in range(3)])\n", - "pm.draw(normal_dists)" + "draw(normal_dists)" ] }, { @@ -196,7 +209,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": { "pycharm": { "name": "#%%\n" @@ -206,41 +219,41 @@ { "data": { "text/plain": [ - "array([ 1.10453926, 0.93416091, -0.27578331])" + "array([ 0.98810294, -0.07003785, -0.37962748])" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normal_dists = pm.Normal.dist(shape=(3,))\n", - "pm.draw(normal_dists)" + "draw(normal_dists)" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([[ 1.17265064, 0.42953598, -0.28644594],\n", - " [ 1.1532523 , -1.42009449, 1.75785042],\n", - " [ 1.27788459, 0.24717247, -0.05186768],\n", - " [ 0.63788917, 1.40202128, -0.02625937]])" + "array([[ 7.99932116e-04, -1.94407945e+00, 3.90451962e-01],\n", + " [ 1.10657367e+00, 6.49042149e-01, -1.09450185e+00],\n", + " [-2.96226305e-01, 1.41884595e+00, -1.31589441e+00],\n", + " [ 1.53109449e+00, -7.73771737e-01, 2.37418367e+00]])" ] }, - "execution_count": 7, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normal_dists = pm.Normal.dist(shape=(4, 3))\n", - "pm.draw(normal_dists)" + "draw(normal_dists)" ] }, { @@ -278,7 +291,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": { "pycharm": { "name": "#%%\n" @@ -288,17 +301,17 @@ { "data": { "text/plain": [ - "array([ 0.20526339, -1.31902695, 0.46685689])" + "array([ 0.81833093, -0.2891973 , 1.2399946 ])" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normal_dists = pm.Normal.dist(mu=np.array([0, 0, 0]), sigma=np.array([1, 1, 1]))\n", - "pm.draw(normal_dists)" + "draw(normal_dists)" ] }, { @@ -316,7 +329,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": { "pycharm": { "name": "#%%\n" @@ -326,16 +339,16 @@ { "data": { "text/plain": [ - "array([ 0.99993126, 9.99984543, 100.00003259])" + "array([ 0.99989975, 10.00009874, 100.00004215])" ] }, - "execution_count": 9, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "pm.draw(pm.Normal.dist(mu=[1, 10, 100], sigma=0.0001))" + "draw(pm.Normal.dist(mu=[1, 10, 100], sigma=0.0001))" ] }, { @@ -351,7 +364,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": { "pycharm": { "name": "#%%\n" @@ -364,7 +377,7 @@ "[array([ 1, 10, 100]), array([0.0001, 0.0001, 0.0001])]" ] }, - "execution_count": 10, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -382,7 +395,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -390,12 +403,12 @@ "output_type": "stream", "text": [ "shape mismatch: objects cannot be broadcast to a single shape. Mismatch is between arg 0 with shape (3,) and arg 1 with shape (2,).\n", - "Apply node that caused the error: normal_rv{0, (0, 0), floatX, True}(RandomGeneratorSharedVariable(), TensorConstant{[]}, TensorConstant{11}, TensorConstant{[ 1 10 100]}, TensorConstant{(2,) of 0.1})\n", + "Apply node that caused the error: normal_rv{0, (0, 0), floatX, True}(RandomGeneratorSharedVariable(), TensorConstant{[]}, TensorConstant{11}, TensorConstant{[ 1 10 100]}, TensorConstant{(2,) of 0.1})\n", "Toposort index: 0\n", "Inputs types: [RandomGeneratorType, TensorType(int64, (0,)), TensorType(int64, ()), TensorType(int64, (3,)), TensorType(float64, (2,))]\n", "Inputs shapes: ['No shapes', (0,), (), (3,), (2,)]\n", "Inputs strides: ['No strides', (8,), (), (8,), (8,)]\n", - "Inputs values: [Generator(PCG64) at 0x7F284D96BE60, array([], dtype=int64), array(11), array([ 1, 10, 100]), array([0.1, 0.1])]\n", + "Inputs values: [Generator(PCG64) at 0x7FC5CF5973E0, array([], dtype=int64), array(11), array([ 1, 10, 100]), array([0.1, 0.1])]\n", "Outputs clients: [['output'], ['output']]\n", "\n", "HINT: Re-running with most Aesara optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the Aesara flag 'optimizer=fast_compile'. If that does not work, Aesara optimizations can be disabled with 'optimizer=None'.\n", @@ -406,7 +419,7 @@ "source": [ "try:\n", " # shapes of (3,) and (2,) can't be broadcasted together\n", - " pm.draw(pm.Normal.dist(mu=[1, 10, 100], sigma=[0.1, 0.1]))\n", + " draw(pm.Normal.dist(mu=[1, 10, 100], sigma=[0.1, 0.1]))\n", "except ValueError as error:\n", " print(error)" ] @@ -427,23 +440,23 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([0.01360448, 0.11874881, 2.71238628])" + "array([-0.49526775, -0.94608062, 1.66397913])" ] }, - "execution_count": 12, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normal_dists = pm.Normal.dist(mu=np.array([0, 1, 2]), sigma=1, shape=(3,))\n", - "pm.draw(normal_dists)" + "draw(normal_dists)" ] }, { @@ -455,26 +468,26 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([[-0.22475842, 1.1818126 , 1.59941035],\n", - " [-1.18278597, 1.75896918, 1.87504772],\n", - " [-1.48208843, 0.00341356, 0.66390724],\n", - " [-1.55003988, 2.83424746, 2.49958085]])" + "array([[ 2.22626513, 2.12938134, 0.49074886],\n", + " [ 0.08312601, 1.05049093, 1.91718083],\n", + " [-0.68191815, 1.43771096, 1.76780399],\n", + " [-0.59883241, 0.26954893, 2.74319335]])" ] }, - "execution_count": 13, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normal_dists = pm.Normal.dist(mu=np.array([0, 1, 2]), sigma=1, shape=(4, 3))\n", - "pm.draw(normal_dists)" + "draw(normal_dists)" ] }, { @@ -486,7 +499,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": { "scrolled": true }, @@ -496,12 +509,12 @@ "output_type": "stream", "text": [ "shape mismatch: objects cannot be broadcast to a single shape. Mismatch is between arg 0 with shape (3, 4) and arg 1 with shape (3,).\n", - "Apply node that caused the error: normal_rv{0, (0, 0), floatX, True}(RandomGeneratorSharedVariable(), TensorConstant{[3 4]}, TensorConstant{11}, TensorConstant{[0 1 2]}, TensorConstant{1.0})\n", + "Apply node that caused the error: normal_rv{0, (0, 0), floatX, True}(RandomGeneratorSharedVariable(), TensorConstant{[3 4]}, TensorConstant{11}, TensorConstant{[0 1 2]}, TensorConstant{1.0})\n", "Toposort index: 0\n", "Inputs types: [RandomGeneratorType, TensorType(int64, (2,)), TensorType(int64, ()), TensorType(int64, (3,)), TensorType(float64, ())]\n", "Inputs shapes: ['No shapes', (2,), (), (3,), ()]\n", "Inputs strides: ['No strides', (8,), (), (8,), ()]\n", - "Inputs values: [Generator(PCG64) at 0x7F284D6B83C0, array([3, 4]), array(11), array([0, 1, 2]), array(1.)]\n", + "Inputs values: [Generator(PCG64) at 0x7FC5CF594660, array([3, 4]), array(11), array([0, 1, 2]), array(1.)]\n", "Outputs clients: [['output'], ['output']]\n", "\n", "HINT: Re-running with most Aesara optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the Aesara flag 'optimizer=fast_compile'. If that does not work, Aesara optimizations can be disabled with 'optimizer=None'.\n", @@ -511,7 +524,7 @@ ], "source": [ "try:\n", - " pm.draw(pm.Normal.dist(mu=np.array([0, 1, 2]), sigma=1, shape=(3, 4)))\n", + " draw(pm.Normal.dist(mu=np.array([0, 1, 2]), sigma=1, shape=(3, 4)))\n", "except ValueError as error:\n", " print(error)" ] @@ -525,25 +538,25 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([[-1.17503239, -1.35392578, 0.9645284 , 1.36791229],\n", - " [ 0.7740332 , 1.89822562, 1.94041417, 2.0301242 ],\n", - " [ 1.98223723, 3.10563644, 3.03044539, -0.71757045]])" + "array([[-0.73397401, -0.18717845, -0.78548049, 1.64478883],\n", + " [ 3.54543846, 1.22954216, 2.13674063, 1.94194106],\n", + " [ 0.85294471, 3.52041332, 2.94428975, 3.25944187]])" ] }, - "execution_count": 15, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "transposed_normals = pm.Normal.dist(mu=np.array([0, 1, 2]), sigma=1, shape=(4, 3)).T\n", - "pm.draw(transposed_normals)" + "draw(transposed_normals)" ] }, { @@ -555,7 +568,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -565,23 +578,23 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(array([-1.79527244, 0.59187417, -0.12458178]),\n", - " array([-0.34580396, -0.34580396, -0.34580396]))" + "(array([-0.45755879, 1.59975702, 0.20546749]),\n", + " array([0.29866199, 0.29866199, 0.29866199]))" ] }, - "execution_count": 17, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "pm.draw(vector_normals), pm.draw(broadcasted_normal)" + "draw(vector_normals), draw(broadcasted_normal)" ] }, { @@ -608,7 +621,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "metadata": { "pycharm": { "name": "#%%\n" @@ -618,17 +631,17 @@ { "data": { "text/plain": [ - "(array([ 0.23006493, -0.51221089, 1.15872558]), 1)" + "(array([0.55390975, 2.17440418, 1.83014764]), 1)" ] }, - "execution_count": 18, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mvnormal_dist = pm.MvNormal.dist(mu=np.ones(3), cov=np.eye(3))\n", - "mvnormal_draw = pm.draw(mvnormal_dist)\n", + "mvnormal_draw = draw(mvnormal_dist)\n", "mvnormal_draw, mvnormal_draw.ndim" ] }, @@ -645,7 +658,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 20, "metadata": { "pycharm": { "name": "#%%\n" @@ -658,7 +671,7 @@ "1" ] }, - "execution_count": 19, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -680,7 +693,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 21, "metadata": { "pycharm": { "name": "#%%\n" @@ -690,17 +703,17 @@ { "data": { "text/plain": [ - "(array([1.56344461]), 1)" + "(array([-0.68893796]), 1)" ] }, - "execution_count": 20, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "smallest_mvnormal_dist = pm.MvNormal.dist(mu=[1], cov=[[1]])\n", - "smallest_mvnormal_draw = pm.draw(smallest_mvnormal_dist)\n", + "smallest_mvnormal_draw = draw(smallest_mvnormal_dist)\n", "smallest_mvnormal_draw, smallest_mvnormal_draw.ndim" ] }, @@ -728,7 +741,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 22, "metadata": { "pycharm": { "name": "#%%\n" @@ -738,17 +751,17 @@ { "data": { "text/plain": [ - "array([3])" + "array([0.57262853, 0.34230354, 1.96818163])" ] }, - "execution_count": 21, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "explicit_mvnormal = pm.MvNormal.dist(mu=np.ones(3), cov=np.eye(3), shape=(3,))\n", - "explicit_mvnormal.shape.eval()" + "draw(explicit_mvnormal)" ] }, { @@ -760,23 +773,23 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([3])" + "array([1.0623799 , 0.84622693, 0.34046237])" ] }, - "execution_count": 22, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ignored_shape_mvnormal = pm.MvNormal.dist(mu=np.ones(3), cov=np.eye(3), shape=(4,))\n", - "explicit_mvnormal.shape.eval()" + "draw(ignored_shape_mvnormal)" ] }, { @@ -803,7 +816,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 24, "metadata": { "pycharm": { "name": "#%%\n" @@ -813,20 +826,20 @@ { "data": { "text/plain": [ - "array([[0, 2, 3],\n", - " [1, 2, 2],\n", - " [0, 0, 5],\n", + "array([[2, 0, 3],\n", + " [1, 1, 3],\n", " [0, 2, 3],\n", - " [0, 2, 3]])" + " [0, 1, 4],\n", + " [1, 0, 4]])" ] }, - "execution_count": 23, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "pm.draw(pm.Multinomial.dist(n=5, p=[0.1, 0.3, 0.6], shape=(5, 3)))" + "draw(pm.Multinomial.dist(n=5, p=[0.1, 0.3, 0.6], shape=(5, 3)))" ] }, { @@ -842,26 +855,26 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[0, 1, 4],\n", + " [0, 0, 5],\n", " [3, 1, 1],\n", - " [1, 0, 4],\n", - " [0, 2, 3],\n", - " [1, 0, 4]])" + " [0, 1, 4],\n", + " [0, 2, 3]])" ] }, - "execution_count": 24, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "pm.draw(pm.Multinomial.dist(n=5, p=[0.1, 0.3, 0.6], shape=(5, 4)))" + "draw(pm.Multinomial.dist(n=5, p=[0.1, 0.3, 0.6], shape=(5, 4)))" ] }, { @@ -873,24 +886,24 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([[0, 3, 2],\n", - " [0, 3, 2],\n", - " [0, 0, 5]])" + "array([[2, 0, 3],\n", + " [1, 3, 1],\n", + " [1, 1, 3]])" ] }, - "execution_count": 25, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "pm.draw(pm.Multinomial.dist(n=5, p=[0.1, 0.3, 0.6], shape=(3, 5)))" + "draw(pm.Multinomial.dist(n=5, p=[0.1, 0.3, 0.6], shape=(3, 5)))" ] }, { @@ -902,25 +915,25 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([[1, 0, 0, 0, 0],\n", - " [3, 2, 1, 2, 2],\n", - " [1, 3, 4, 3, 3]])" + "array([[0, 0, 0, 0, 0],\n", + " [2, 2, 1, 0, 3],\n", + " [3, 3, 4, 5, 2]])" ] }, - "execution_count": 26, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "transposed_multinomials = pm.Multinomial.dist(n=5, p=[0.1, 0.3, 0.6], shape=(5, 3)).T\n", - "pm.draw(transposed_multinomials)" + "draw(transposed_multinomials)" ] }, { @@ -947,7 +960,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 28, "metadata": { "pycharm": { "name": "#%%\n" @@ -957,18 +970,18 @@ { "data": { "text/plain": [ - "array([[0, 1, 4],\n", - " [0, 5, 5]])" + "array([[1, 2, 2],\n", + " [0, 3, 7]])" ] }, - "execution_count": 27, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "multinomial_dist = pm.Multinomial.dist(n=[5, 10], p=[0.1, 0.3, 0.6])\n", - "pm.draw(multinomial_dist)" + "draw(multinomial_dist)" ] }, { @@ -984,7 +997,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 29, "metadata": { "pycharm": { "name": "#%%\n" @@ -994,17 +1007,17 @@ { "data": { "text/plain": [ - "array([[1, 1, 3],\n", - " [1, 0, 9]])" + "array([[2, 2, 1],\n", + " [0, 3, 7]])" ] }, - "execution_count": 28, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "pm.draw(pm.Multinomial.dist(n=[5, 10], p=[[0.1, 0.3, 0.6], [0.1, 0.3, 0.6]]))" + "draw(pm.Multinomial.dist(n=[5, 10], p=[[0.1, 0.3, 0.6], [0.1, 0.3, 0.6]]))" ] }, { @@ -1020,7 +1033,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 30, "metadata": { "pycharm": { "name": "#%%\n" @@ -1053,7 +1066,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 31, "metadata": { "pycharm": { "name": "#%%\n" @@ -1071,11 +1084,11 @@ { "data": { "text/plain": [ - "array([[1, 1, 3],\n", - " [3, 3, 4]])" + "array([[1, 0, 4],\n", + " [1, 2, 7]])" ] }, - "execution_count": 30, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -1083,7 +1096,7 @@ "source": [ "def core_multinomial(n, p):\n", " print(\">>\", n, p)\n", - " return pm.draw(pm.Multinomial.dist(n, p))\n", + " return draw(pm.Multinomial.dist(n, p))\n", "\n", "\n", "vectorized_multinomial = np.vectorize(core_multinomial, signature=\"(),(p)->(p)\")\n", @@ -1103,7 +1116,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 32, "metadata": { "pycharm": { "name": "#%%\n" @@ -1116,7 +1129,7 @@ "(0, 1)" ] }, - "execution_count": 31, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -1134,7 +1147,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -1142,12 +1155,12 @@ "output_type": "stream", "text": [ "operands could not be broadcast together with remapped shapes [original->remapped]: (2,) and requested shape (3,)\n", - "Apply node that caused the error: multinomial_rv{1, (0, 1), int64, True}(RandomGeneratorSharedVariable(), TensorConstant{[]}, TensorConstant{4}, TensorConstant{[ 5 10]}, TensorConstant{[[0.1 0.3 .. 0.3 0.6]]})\n", + "Apply node that caused the error: multinomial_rv{1, (0, 1), int64, True}(RandomGeneratorSharedVariable(), TensorConstant{[]}, TensorConstant{4}, TensorConstant{[ 5 10]}, TensorConstant{[[0.1 0.3 .. 0.3 0.6]]})\n", "Toposort index: 0\n", "Inputs types: [RandomGeneratorType, TensorType(int64, (0,)), TensorType(int64, ()), TensorType(int64, (2,)), TensorType(float64, (3, 3))]\n", "Inputs shapes: ['No shapes', (0,), (), (2,), (3, 3)]\n", "Inputs strides: ['No strides', (8,), (), (8,), (24, 8)]\n", - "Inputs values: [Generator(PCG64) at 0x7F28450E1540, array([], dtype=int64), array(4), array([ 5, 10]), 'not shown']\n", + "Inputs values: [Generator(PCG64) at 0x7FC5C6D24BA0, array([], dtype=int64), array(4), array([ 5, 10]), 'not shown']\n", "Outputs clients: [['output'], ['output']]\n", "\n", "HINT: Re-running with most Aesara optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the Aesara flag 'optimizer=fast_compile'. If that does not work, Aesara optimizations can be disabled with 'optimizer=None'.\n", @@ -1157,7 +1170,7 @@ ], "source": [ "try:\n", - " pm.draw(pm.Multinomial.dist(n=[5, 10], p=[[0.1, 0.3, 0.6], [0.1, 0.3, 0.6], [0.1, 0.3, 0.6]]))\n", + " draw(pm.Multinomial.dist(n=[5, 10], p=[[0.1, 0.3, 0.6], [0.1, 0.3, 0.6], [0.1, 0.3, 0.6]]))\n", "except ValueError as error:\n", " print(error)" ] @@ -1186,7 +1199,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 34, "metadata": { "pycharm": { "name": "#%%\n" @@ -1196,17 +1209,17 @@ { "data": { "text/plain": [ - "array([[0, 2, 3],\n", - " [1, 2, 7]])" + "array([[0, 1, 4],\n", + " [4, 1, 5]])" ] }, - "execution_count": 33, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "pm.draw(pm.Multinomial.dist(n=[5, 10], p=[0.1, 0.3, 0.6], shape=(2, 3)))" + "draw(pm.Multinomial.dist(n=[5, 10], p=[0.1, 0.3, 0.6], shape=(2, 3)))" ] }, { @@ -1218,7 +1231,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 35, "metadata": {}, "outputs": [ { @@ -1226,12 +1239,12 @@ "output_type": "stream", "text": [ "shape mismatch: objects cannot be broadcast to a single shape\n", - "Apply node that caused the error: multinomial_rv{1, (0, 1), int64, True}(RandomGeneratorSharedVariable(), TensorConstant{[2 4]}, TensorConstant{4}, TensorConstant{[ 5 10]}, TensorConstant{[0.1 0.3 0.6]})\n", + "Apply node that caused the error: multinomial_rv{1, (0, 1), int64, True}(RandomGeneratorSharedVariable(), TensorConstant{[2 4]}, TensorConstant{4}, TensorConstant{[ 5 10]}, TensorConstant{[0.1 0.3 0.6]})\n", "Toposort index: 0\n", "Inputs types: [RandomGeneratorType, TensorType(int64, (2,)), TensorType(int64, ()), TensorType(int64, (2,)), TensorType(float64, (3,))]\n", "Inputs shapes: ['No shapes', (2,), (), (2,), (3,)]\n", "Inputs strides: ['No strides', (8,), (), (8,), (8,)]\n", - "Inputs values: [Generator(PCG64) at 0x7F284503D7E0, array([2, 4]), array(4), array([ 5, 10]), array([0.1, 0.3, 0.6])]\n", + "Inputs values: [Generator(PCG64) at 0x7FC5C6BA1D20, array([2, 4]), array(4), array([ 5, 10]), array([0.1, 0.3, 0.6])]\n", "Outputs clients: [['output'], ['output']]\n", "\n", "HINT: Re-running with most Aesara optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the Aesara flag 'optimizer=fast_compile'. If that does not work, Aesara optimizations can be disabled with 'optimizer=None'.\n", @@ -1241,7 +1254,7 @@ ], "source": [ "try:\n", - " pm.draw(pm.Multinomial.dist(n=[5, 10], p=[0.1, 0.3, 0.6], shape=(2, 4, 3)))\n", + " draw(pm.Multinomial.dist(n=[5, 10], p=[0.1, 0.3, 0.6], shape=(2, 4, 3)))\n", "except ValueError as error:\n", " print(error)" ] @@ -1266,7 +1279,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 36, "metadata": { "pycharm": { "name": "#%%\n" @@ -1307,7 +1320,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 37, "metadata": { "pycharm": { "name": "#%%\n" @@ -1333,22 +1346,22 @@ "\n", "3\n", "\n", - "\n", - "\n", - "y\n", - "\n", - "y\n", - "~\n", - "Normal\n", - "\n", "\n", - "\n", + "\n", "x\n", "\n", "x\n", "~\n", "Normal\n", "\n", + "\n", + "\n", + "y\n", + "\n", + "y\n", + "~\n", + "Normal\n", + "\n", "\n", "\n", "x->y\n", @@ -1373,10 +1386,10 @@ "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 36, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -1400,7 +1413,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 38, "metadata": { "pycharm": { "name": "#%%\n" @@ -1459,10 +1472,10 @@ "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 37, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -1496,7 +1509,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 39, "metadata": { "pycharm": { "name": "#%%\n" @@ -1561,10 +1574,10 @@ "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 38, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -1593,7 +1606,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 40, "metadata": { "pycharm": { "name": "#%%\n" @@ -1631,10 +1644,10 @@ "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 39, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -1675,7 +1688,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 41, "metadata": { "pycharm": { "name": "#%%\n" @@ -1714,30 +1727,30 @@ "~\n", "MvNormal\n", "\n", - "\n", + "\n", "\n", - "matrix (explicit)\n", - "\n", - "matrix (explicit)\n", - "~\n", - "MvNormal\n", + "matrix (implicit)\n", + "\n", + "matrix (implicit)\n", + "~\n", + "MvNormal\n", "\n", - "\n", + "\n", "\n", - "matrix (implicit)\n", - "\n", - "matrix (implicit)\n", - "~\n", - "MvNormal\n", + "matrix (explicit)\n", + "\n", + "matrix (explicit)\n", + "~\n", + "MvNormal\n", "\n", "\n", "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 40, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" }