Изменение формы распределений
Распределения случайных величин, представляющих собой массивы, например MultivariateDistribution или MatrixDistribution, допускают изменение формы.
#
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})
Возвращает распределение MultivariateDistribution вектора vec(X), где X — случайная величина с распределением d.
Реализация по умолчанию возвращает ReshapedDistribution. Однако она может возвращать более оптимизированные распределения для определенных типов распределений и числа измерений. Поэтому рекомендуется использовать vec вместо конструктора ReshapedDistribution.
Реализация
Так как vec(d) определяется как reshape(d, length(d)), следует реализовать reshape(d, ::Tuple{Int}), а не vec.
См. также описание reshape.