Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/src/fit.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ The function `fit_mle` is for maximum likelihood estimation.
### Synopsis

```@docs
fit(D, x)
fit(D, x, w)
fit(::Type{<:Distribution}, x)
fit_mle(D, x)
fit_mle(D, x, w)
```
Expand Down
16 changes: 14 additions & 2 deletions docs/src/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,26 @@ Base.rand(::Distributions.Sampleable)
Distributions.VariateForm
```

The `VariateForm` subtypes defined in `Distributions.jl` are:
The most commonly used `VariateForm` is the `ArrayLikeVariate`:
```@docs
Distributions.ArrayLikeVariate
```

The `ArrayLikeVariate` types defined in `Distributions.jl` are:

**Type** | **A single sample** | **Multiple samples**
--- | --- |---
`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

`Distributions.jl` also defines some other `VariateForm` subtypes

```@docs
Distributions.NamedTupleVariate
Distributions.CholeskyVariate
```

### ValueSupport

```@docs
Expand Down Expand Up @@ -70,7 +82,7 @@ We use `Distribution`, a subtype of `Sampleable` as defined below, to capture pr
abstract type Distribution{F<:VariateForm,S<:ValueSupport} <: Sampleable{F,S} end
```

```@doc
```@docs
Distributions.Distribution
```

Expand Down
2 changes: 1 addition & 1 deletion src/reshaped.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ end
Return a [`Distribution`](@ref) of `reshape(X, dims)` where `X` is a random variable with
distribution `d`.

The default implementation returns a [`ReshapedDistribution`](@ref). However, it can return
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`.
Expand Down
10 changes: 10 additions & 0 deletions src/univariates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ logpdf(d::UnivariateDistribution, x::Real)
# extract value from array of zero dimension
logpdf(d::UnivariateDistribution, x::AbstractArray{<:Real,0}) = logpdf(d, first(x))

"""
loglikelihood(d::UnivariateDistribution, x)

The log-likelihood of distribution `d` with respect to `x`.

Here, `x` can be any output of `rand(d, dims...)` and `rand!(d, x)`.
For univariate distributions, `x` therfore must be a scalar or
an array with an arbitrary number of dimensions.
"""
Comment on lines +329 to +337

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already covered by

"""
loglikelihood(d::Distribution{ArrayLikeVariate{N}}, x) where {N}
The log-likelihood of distribution `d` with respect to all variate(s) contained in `x`.
Here, `x` can be any output of `rand(d, dims...)` and `rand!(d, x)`. For instance, `x` can
be
- an array of dimension `N` with `size(x) == size(d)`,
- an array of dimension `N + 1` with `size(x)[1:N] == size(d)`, or
- an array of arrays `xi` of dimension `N` with `size(xi) == size(d)`.
"""

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I did basically copy it from that docstring, to cover the docstring requested in univariate.md, line 76. Should the signature for that method be replaced with the method defined in common.jl? It did seem weird that there was a docstring listing for a method that didn't have those specific types, but I wasn't sure if there was a specific documentation need that was served, with the implementation still being the same somehow.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, no, the generic method is the relevant one in this case as well. I'm not sure what's the best way to handle this.

loglikelihood(d::UnivariateDistribution, x::AbstractArray)
# loglikelihood for `Real`
Base.@propagate_inbounds loglikelihood(d::UnivariateDistribution, x::Real) = logpdf(d, x)

Expand Down
Loading