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

Add QQPair for use in qq-plots

parent 9e818eb7
......@@ -71,6 +71,7 @@ export # types
Uniform,
Weibull,
Wishart,
QQPair,
# methods
binaryentropy, # entropy of distribution in bits
ccdf, # complementary cdf, i.e. 1 - cdf
......@@ -117,6 +118,7 @@ export # types
pdf, # probability density function (ContinuousDistribution)
pmf, # probability mass function (DiscreteDistribution)
quantile, # inverse of cdf (defined for p in (0,1))
qqbuild, # build a paired quantiles data structure for qqplots
rand, # random sampler
rand!, # replacement random sampler
sample, # sample from a source array
......@@ -241,4 +243,6 @@ include("functionals.jl")
include("conjugates.jl")
include("qq.jl")
end # module
immutable QQPair
qx::Vector{Float64}
qy::Vector{Float64}
end
function qqbuild(x::Vector, y::Vector)
n = min(length(x), length(y))
grid = [0.0:(1 / (n - 1)):1.0]
qx = quantile(x, grid)
qy = quantile(y, grid)
return QQPair(qx, qy)
end
function qqbuild(x::Vector, d::UnivariateDistribution)
n = length(x)
grid = [(1 / (n - 1)):(1 / (n - 1)):(1.0 - (1 / (n - 1)))]
qx = quantile(x, grid)
qd = quantile(d, grid)
return QQPair(qx, qd)
end
function qqbuild(d::UnivariateDistribution, x::Vector)
n = length(x)
grid = [(1 / (n - 1)):(1 / (n - 1)):(1.0 - (1 / (n - 1)))]
qd = quantile(d, grid)
qx = quantile(x, grid)
return QQPair(qd, qx)
end
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