pm.Normal, what is the `shape` parameter for a normal distribution?

Hello PyMC community again,

I have never encountered a shape parameter for Normal, until PyMC. Source for where I encountered this (search pm.Normal)

A shape parameter is not mentioned in Normal Distribution’s Wikipedia page either. In fact, this Wikipedia page explicitly states that the shape parameter is not applicable for a Normal Distribution. Similarly, PyMC’s documentation does not have a shape parameter either.

How do I interpret something like such:
foo = pm.Normal('foo', mu=0, sd=1, shape=5)


Removing the shape parameter raised an error:
IndexError: too many indices for array

The shape argument has nothing to do with the shape parameter described by Wikipedia. Rather, it is used to indicate that a variable represents an array of random variables, each with the distribution described by parameters such as mu and sd.

An example of this is in Getting started with PyMC3: " The beta variable has an additional shape argument to denote it as a vector-valued parameter of size 2. The shape argument is available for all distributions and specifies the length or shape of the random variable, but is optional for scalar variables, since it defaults to a value of one. It can be an integer, to specify an array, or a tuple, to specify a multidimensional array ( e.g. shape=(5,7) makes random variable that takes on 5 by 7 matrix values)."


I just realized I had not replied to your response, but I did read it. It was very helpful, thank you jjramsey.

So what is the difference with a multivariate normal?

If you use pm.Normal, the resulting array will contain random variables which will all be univariate, independent draws (but they don’t necessarily need to be identically distributed - you can use arrays in mu and sd to set different means and variances). If you want draws which are correlated across entries, you have to use pm.MvNormal.