# Reshaping distributions

Distributions of array variates such as `MultivariateDistribution`

s and `MatrixDistribution`

s can be reshaped.

`Base.reshape`

— Function```
reshape(d::Distribution{<:ArrayLikeVariate}, dims::Int...)
reshape(d::Distribution{<:ArrayLikeVariate}, dims::Dims)
```

Return a `Distribution`

of `reshape(X, dims)`

where `X`

is a random variable with distribution `d`

.

The default implementation returns a `ReshapedDistribution`

. However, it can return more optimized distributions for specific types of distributions and numbers of dimensions. Therefore it is recommended to use `reshape`

instead of the constructor of `ReshapedDistribution`

.

**Implementation**

Since `reshape(d, dims::Int...)`

calls `reshape(d, dims::Dims)`

, one should implement `reshape(d, ::Dims)`

for desired distributions `d`

.

See also: `vec`

`Base.vec`

— Function`vec(d::Distribution{<:ArrayLikeVariate})`

Return a `MultivariateDistribution`

of `vec(X)`

where `X`

is a random variable with distribution `d`

.

The default implementation returns a `ReshapedDistribution`

. However, it can return more optimized distributions for specific types of distributions and numbers of dimensions. Therefore it is recommended to use `vec`

instead of the constructor of `ReshapedDistribution`

.

**Implementation**

Since `vec(d)`

is defined as `reshape(d, length(d))`

one should implement `reshape(d, ::Tuple{Int})`

rather than `vec`

.

See also: `reshape`