Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit c26832ce authored by John Myles White's avatar John Myles White

Initial port of material from my old branch

New functions:
 * entropy()
 * binaryentropy()
 * modes()

New distributions:
 * BetaPrime
 * Erlang
 * Triangular
parent e8eec01b
......@@ -21,6 +21,7 @@ Many distribution types also provide useful theoretical information about the di
As of v0.0.0, the following distributions have been implemented:
* Arcsine
* Bernoulli
* Beta
* Binomial
......@@ -28,30 +29,38 @@ As of v0.0.0, the following distributions have been implemented:
* Cauchy
* Chisq
* Dirichlet
* DiscreteUniform
* Exponential
* FDist
* Gamma
* Geometric
* HyperGeometric
* Laplace
* Logistic
* logNormal
* MixtureModel
* Multinomial
* MultivariateNormal
* NegativeBinomial
* NoncentralBeta
* NoncentralChisq
* NoncentralF
* NoncentralT
* Normal
* Pareto
* Poisson
* Rayleigh
* TDist
* Uniform
* Weibull
## Simple Examples
using Distributions
x = rand(Normal(0.0, 1.0), 10_000)
mean(x)
d = Beta(1.0, 9.0)
pdf(d, 0.9)
quantile(d, 0.1)
......
This diff is collapsed.
##
##
## String representations
##
##
function show(io::IO, d::Distribution)
print(io, @sprintf "%s distribution\n" typeof(d))
for parameter in typeof(d).names
if isa(d.(parameter), AbstractArray)
param = strcat(ucfirst(string(parameter)), ":\n", d.(parameter), "\n")
else
param = strcat(ucfirst(string(parameter)), ": ", d.(parameter), "\n")
end
print(io, param)
end
m = mean(d)
if isa(m, AbstractArray)
print(io, strcat("Mean:\n", m, "\n"))
else
print(io, strcat("Mean: ", m, "\n"))
end
v = var(d)
if isa(v, AbstractArray)
print(io, strcat("Variance:\n", v))
else
print(io, strcat("Variance: ", v))
end
end
......@@ -43,9 +43,7 @@ end
# Additional tests on the Multinomial and Dirichlet constructors
d = Multinomial(1, [0.5, 0.4, 0.1])
d = Multinomial(1, 3)
d = Multinomial(3)
d = Multinomial(1, [0.6; 0.4])
d = Multinomial(1, [0.6; 0.4]')
d = Multinomial(2)
mean(d)
var(d)
@assert insupport(d, [1, 0])
......@@ -64,8 +62,6 @@ rand!(d, A)
d = Dirichlet([1.0, 2.0, 1.0])
d = Dirichlet(3)
d = Dirichlet([1.0; 2.0; 1.0])
d = Dirichlet([1.0; 2.0; 1.0]')
mean(d)
var(d)
insupport(d, [0.1, 0.8, 0.1])
......@@ -78,7 +74,7 @@ rand!(d, A)
d = Categorical([0.25, 0.5, 0.25])
d = Categorical(3)
d = Categorical([0.25; 0.5; 0.25])
d = Categorical([0.25, 0.5, 0.25])
@assert !insupport(d, 0)
@assert insupport(d, 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment