Skip to content

Commit

Permalink
Introduce ArrayLikeVariate as common supertype for Univariate, Multiv…
Browse files Browse the repository at this point in the history
…ariate and Matrixvariate (#1313)

Co-authored-by: Moritz Schauer <[email protected]>
  • Loading branch information
oschulz and mschauer authored May 13, 2021
1 parent 2af8703 commit b35f091
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
6 changes: 3 additions & 3 deletions docs/src/starting.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ julia> rand(Normal(1, 2), 100)

The package contains a large number of additional distributions of three main types:

* `Univariate`
* `Multivariate`
* `Matrixvariate`
* `Univariate == ArrayLikeVariate{0}`
* `Multivariate == ArrayLikeVariate{1}`
* `Matrixvariate == ArrayLikeVariate{2}`

Each type splits further into `Discrete` and `Continuous`.

Expand Down
6 changes: 3 additions & 3 deletions docs/src/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ The `VariateForm` sub-types defined in `Distributions.jl` are:

**Type** | **A single sample** | **Multiple samples**
--- | --- |---
`Univariate` | a scalar number | A numeric array of arbitrary shape, each element being a sample
`Multivariate` | a numeric vector | A matrix, each column being a sample
`Matrixvariate` | a numeric matrix | An array of matrices, each element being a sample matrix
`Univariate == ArrayLikeVariate{0}` | a scalar number | A numeric array of arbitrary shape, each element being a sample
`Multivariate == ArrayLikeVariate{1}` | a numeric vector | A matrix, each column being a sample
`Matrixvariate == ArrayLikeVariate{2}` | a numeric matrix | An array of matrices, each element being a sample matrix

### ValueSupport

Expand Down
1 change: 1 addition & 0 deletions src/Distributions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export

# generic types
VariateForm,
ArrayLikeVariate,
ValueSupport,
Univariate,
Multivariate,
Expand Down
17 changes: 12 additions & 5 deletions src/common.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
## sample space/domain

"""
`F <: VariateForm` specifies the form of the variate or
dimension of a sample, univariate (scalar), multivariate (vector), matrix-variate (matrix).
`F <: VariateForm` specifies the form or shape of the variate or a sample.
"""
abstract type VariateForm end
struct Univariate <: VariateForm end
struct Multivariate <: VariateForm end
struct Matrixvariate <: VariateForm end

"""
`F <: ArrayLikeVariate{N}` specifies the number of axes of a variate or
a sample with an array-like shape, e.g. univariate (scalar, `N == 0`),
multivariate (vector, `N == 1`) or matrix-variate (matrix, `N == 2`).
"""
abstract type ArrayLikeVariate{N} <: VariateForm end

const Univariate = ArrayLikeVariate{0}
const Multivariate = ArrayLikeVariate{1}
const Matrixvariate = ArrayLikeVariate{2}

"""
`S <: ValueSupport` specifies the support of sample elements,
Expand Down

0 comments on commit b35f091

Please sign in to comment.