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 bbf5c958 authored by John Myles White's avatar John Myles White

Added an Arcsine type

parent 2c72d43d
......@@ -5,6 +5,7 @@ export # types
Distribution,
DiscreteDistribution,
ContinuousDistribution,
Arcsine,
Bernoulli,
Beta,
Binomial,
......@@ -390,6 +391,39 @@ macro _jl_dist_3p(T, b)
end
end
type Arcsine <: ContinuousDistribution
end
function cdf(d::Arcsine, x::Number)
if x < -1.
return 0.
elseif x > 1.
return 1.
else
return (2. / pi) * asin(sqrt((x + 1.) / 2.))
end
end
function insupport(d::Arcsine, x::Number)
if -1. <= x <= 1.
return true
else
return false
end
end
mean(d::Arcsine) = 0.0
median(d::Arcsine) = 0.0
function pdf(d::Arcsine, x::Number)
if insupport(d, x)
1. / (pi * sqrt(1. - x^2))
else
0.
end
end
quantile(d::Arcsine, p::Real) = 2. * sin((pi / 2.) * p)^2 - 1.
rand(d::Arcsine) = sin(2. * pi * rand())
skewness(d::Arcsine) = 0.
var(d::Arcsine) = 1./2.
type Alpha <: ContinuousDistribution
location::Float64
scale::Float64
......
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