Skip to content

Commit 33b9da2

Browse files
authored
Merge branch 'master' into dw/rand_multiple_consistent
2 parents bbf5468 + e470421 commit 33b9da2

File tree

21 files changed

+528
-30
lines changed

21 files changed

+528
-30
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Distributions"
22
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
33
authors = ["JuliaStats"]
4-
version = "0.25.113"
4+
version = "0.25.117"
55

66
[deps]
77
AliasTables = "66dad0bd-aa9a-41b7-9441-69ab47430ed8"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
44

55
[compat]
6-
Documenter = "0.26, 0.27"
6+
Documenter = "1"
77
GR = "0.72.1, 0.73"

docs/make.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Documenter, Distributions
22
import Random: AbstractRNG, rand!
33

4-
makedocs(
4+
makedocs(;
55
sitename = "Distributions.jl",
66
modules = [Distributions],
77
format = Documenter.HTML(; prettyurls = get(ENV, "CI", nothing) == "true"),
@@ -17,16 +17,18 @@ makedocs(
1717
"reshape.md",
1818
"cholesky.md",
1919
"mixture.md",
20+
"product.md",
2021
"order_statistics.md",
2122
"convolution.md",
2223
"fit.md",
2324
"extends.md",
2425
"density_interface.md",
25-
]
26+
],
27+
warnonly = true,
2628
)
2729

2830
deploydocs(;
2931
repo = "github.com/JuliaStats/Distributions.jl.git",
3032
versions = ["stable" => "v^", "v#.#", "dev" => "master"],
31-
push_preview=true,
33+
push_preview = true,
3234
)

docs/src/multivariate.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ MvNormalCanon
5757
MvLogitNormal
5858
MvLogNormal
5959
Dirichlet
60-
Product
6160
```
6261

6362
## Addition Methods
@@ -104,15 +103,6 @@ params{D<:Distributions.AbstractMvLogNormal}(::Type{D},m::AbstractVector,S::Abst
104103
Distributions._logpdf(d::MultivariateDistribution, x::AbstractArray)
105104
```
106105

107-
## Product distributions
108-
109-
```@docs
110-
Distributions.product_distribution
111-
```
112-
113-
Using `product_distribution` is advised to construct product distributions.
114-
For some distributions, it constructs a special multivariate type.
115-
116106
## Index
117107

118108
```@index

docs/src/product.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Product Distributions
2+
3+
Product distributions are joint distributions of multiple independent distributions.
4+
It is recommended to use `product_distribution` to construct product distributions.
5+
Depending on the type of the argument, it may construct a different distribution type.
6+
7+
## Multivariate products
8+
9+
```@docs
10+
Distributions.product_distribution(::AbstractArray{<:Distribution{<:ArrayLikeVariate}})
11+
Distributions.product_distribution(::AbstractVector{<:Normal})
12+
Distributions.ProductDistribution
13+
Distributions.Product
14+
```
15+
16+
## NamedTuple-variate products
17+
18+
```@docs
19+
Distributions.product_distribution(::NamedTuple{<:Any,<:Tuple{Distribution,Vararg{Distribution}}})
20+
Distributions.ProductNamedTupleDistribution
21+
```
22+
23+
## Index
24+
25+
```@index
26+
Pages = ["product.md"]
27+
```

src/Distributions.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export
4141
Multivariate,
4242
Matrixvariate,
4343
CholeskyVariate,
44+
NamedTupleVariate,
4445
Discrete,
4546
Continuous,
4647
Sampleable,
@@ -296,6 +297,7 @@ include("univariates.jl")
296297
include("edgeworth.jl")
297298
include("multivariates.jl")
298299
include("matrixvariates.jl")
300+
include("namedtuple/productnamedtuple.jl")
299301
include("cholesky/lkjcholesky.jl")
300302
include("samplers.jl")
301303

src/cholesky/lkjcholesky.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ function insupport(d::LKJCholesky, R::LinearAlgebra.Cholesky)
107107
return true
108108
end
109109

110-
function StatsBase.mode(d::LKJCholesky)
111-
factors = Matrix{float(partype(d))}(LinearAlgebra.I, size(d))
110+
function mode(d::LKJCholesky; check_args::Bool=true)
111+
@check_args(
112+
LKJCholesky,
113+
@setup= d.η),
114+
(η, η > 1, "mode is defined only when η > 1."),
115+
)
116+
factors = Matrix{eltype(d)}(LinearAlgebra.I, size(d))
112117
return LinearAlgebra.Cholesky(factors, d.uplo, 0)
113118
end
114119

src/common.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ const Univariate = ArrayLikeVariate{0}
1616
const Multivariate = ArrayLikeVariate{1}
1717
const Matrixvariate = ArrayLikeVariate{2}
1818

19+
"""
20+
`F <: NamedTupleVariate{K}` specifies that the variate or a sample is of type
21+
`NamedTuple{K}`.
22+
"""
23+
struct NamedTupleVariate{K} <: VariateForm end
24+
1925
"""
2026
`F <: CholeskyVariate` specifies that the variate or a sample is of type
2127
`LinearAlgebra.Cholesky`.

src/mixtures/mixturemodel.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# finite mixture models
22

33
"""
4+
AbstractMixtureModel <: Distribution
45
5-
All subtypes of `AbstractMixtureModel` should implement the following methods:
6+
All subtypes of `AbstractMixtureModel` should implement the following methods:
67
7-
- ncomponents(d): the number of components
8+
- `ncomponents(d)`: the number of components
89
9-
- component(d, k): return the k-th component
10+
- `component(d, k)`: return the k-th component
1011
11-
- probs(d): return a vector of prior probabilities over components.
12+
- `probs(d)`: return a vector of prior probabilities over components.
1213
"""
1314
abstract type AbstractMixtureModel{VF<:VariateForm,VS<:ValueSupport,C<:Distribution} <: Distribution{VF, VS} end
1415

1516
"""
16-
MixtureModel{VF<:VariateForm,VS<:ValueSupport,C<:Distribution,CT<:Real}
17+
MixtureModel{VF<:VariateForm,VS<:ValueSupport,C<:Distribution,CT<:Real}
18+
1719
A mixture of distributions, parametrized on:
1820
* `VF,VS` variate and support
1921
* `C` distribution family of the mixture

src/multivariate/product.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ An N dimensional `MultivariateDistribution` constructed from a vector of N indep
1010
```julia
1111
Product(Uniform.(rand(10), 1)) # A 10-dimensional Product from 10 independent `Uniform` distributions.
1212
```
13+
14+
!!! note
15+
`Product` is deprecated and will be removed in the next breaking release.
16+
Use [`product_distribution`](@ref) instead.
1317
"""
1418
struct Product{
1519
S<:ValueSupport,

0 commit comments

Comments
 (0)