-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,518 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
name = "BayesBase" | ||
uuid = "b4ee3484-f114-42fe-b91c-797d54a0c67e" | ||
authors = ["Bagaev Dmitry <bvdmitri@gmail.com> and contributors"] | ||
version = "1.0.0-DEV" | ||
authors = ["Bagaev Dmitry <d.v.bagaev@tue.nl> and contributors"] | ||
version = "1.0.0" | ||
|
||
[deps] | ||
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
StatsAPI = "82ae8749-77ed-4fe6-ae5f-f523153014b0" | ||
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" | ||
TinyHugeNumbers = "783c9a47-75a3-44ac-a16b-f1ab7b3acf04" | ||
|
||
[compat] | ||
julia = "1" | ||
Distributions = "0.25" | ||
Random = "1.9" | ||
Statistics = "1.9" | ||
StatsAPI = "1.7" | ||
StatsBase = "0.34" | ||
TinyHugeNumbers = "1.0" | ||
julia = "1.9" | ||
|
||
[extras] | ||
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
CpuId = "adafc99b-e345-5852-983c-f28acb93d879" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823" | ||
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test"] | ||
test = ["Aqua", "CpuId", "Test", "ReTestItems", "LinearAlgebra", "StableRNGs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,72 @@ | ||
module BayesBase | ||
|
||
# Write your package code here. | ||
using TinyHugeNumbers | ||
|
||
using StatsAPI, StatsBase, Statistics, Distributions, Random | ||
|
||
using StatsAPI: params | ||
|
||
export params | ||
|
||
using Statistics: mean, median, std, var, cov | ||
|
||
export mean, median, std, var, cov | ||
|
||
using StatsBase: mode, entropy | ||
|
||
export mode, entropy | ||
|
||
using Distributions: | ||
failprob, | ||
succprob, | ||
insupport, | ||
shape, | ||
scale, | ||
rate, | ||
invcov, | ||
pdf, | ||
logpdf, | ||
logdetcov, | ||
VariateForm, | ||
ValueSupport, | ||
Distribution, | ||
Univariate, | ||
Multivariate, | ||
Matrixvariate, | ||
variate_form, | ||
value_support | ||
|
||
export failprob, | ||
succprob, | ||
insupport, | ||
shape, | ||
scale, | ||
rate, | ||
invcov, | ||
pdf, | ||
logpdf, | ||
logdetcov, | ||
VariateForm, | ||
ValueSupport, | ||
Distribution, | ||
Univariate, | ||
Multivariate, | ||
Matrixvariate, | ||
variate_form, | ||
value_support | ||
|
||
using Base: precision, eltype, convert, length, isapprox | ||
|
||
export precision, eltype, convert, length, isapprox | ||
|
||
using Random: rand, rand! | ||
|
||
export rand, rand! | ||
|
||
include("statsfuns.jl") | ||
include("promotion.jl") | ||
include("prod.jl") | ||
|
||
include("densities/factorizedjoint.jl") | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
export FactorizedJoint | ||
|
||
""" | ||
FactorizedJoint | ||
`FactorizedJoint` represents a joint distribution of independent random variables. | ||
Use `component()` function or square-brackets indexing to access the marginal distribution for individual variables. | ||
Use `components()` function to get a tuple of multipliers. | ||
""" | ||
struct FactorizedJoint{T} | ||
multipliers::T | ||
end | ||
|
||
BayesBase.components(joint::FactorizedJoint) = joint.multipliers | ||
|
||
Base.@propagate_inbounds function BayesBase.component(joint::FactorizedJoint, i::Int) | ||
return getindex(joint, i) | ||
end | ||
Base.@propagate_inbounds function Base.getindex(joint::FactorizedJoint, i::Int) | ||
return getindex(components(joint), i) | ||
end | ||
|
||
BayesBase.length(joint::FactorizedJoint) = length(joint.multipliers) | ||
|
||
function BayesBase.isapprox(x::FactorizedJoint, y::FactorizedJoint; kwargs...) | ||
return length(x) === length(y) && all( | ||
tuple -> isapprox(tuple[1], tuple[2]; kwargs...), | ||
zip(components(x), components(y)), | ||
) | ||
end | ||
|
||
BayesBase.entropy(joint::FactorizedJoint) = mapreduce(entropy, +, components(joint)) | ||
|
||
function BayesBase.paramfloattype(joint::FactorizedJoint) | ||
return BayesBase.paramfloattype(BayesBase.components(joint)) | ||
end | ||
|
||
function BayesBase.convert_paramfloattype(::Type{T}, joint::FactorizedJoint) where {T} | ||
return FactorizedJoint( | ||
map(e -> BayesBase.convert_paramfloattype(T, joint), BayesBase.components(joint)) | ||
) | ||
end |
Oops, something went wrong.