Hi,
I’m very new (2 days) into Julia and I’m having trouble defining and plotting a new distribution using StatPlots
. Here’s my attempt (creating Normal(mu, 2*sigma) just to make things easy):
using Distributions, Plots, StatPlots
importall Distributions
type MyDist <: ContinuousUnivariateDistribution
mu::Float64
sigma::Float64
MyDist(mu, sigma) = new(Float64(mu), Float64(sigma))
end
pdf(d::MyDist, x::Float64) = pdf(Normal(d.mu, 2*d.sigma), x)
rand(d::MyDist) = rand(Normal(d.mu, 2*d.sigma))
sampler(d::MyDist) = sampler(Normal(d.mu, 2*d.sigma))
logpdf(d::MyDist, x::Real) = logpdf(Normal(d.mu, 2*d.sigma), x)
cdf(d::MyDist, x::Real) = cdf(Normal(d.mu, 2*d.sigma), x)
quantile(d::MyDist, q::Real) = quantile(Normal(d.mu, 2*d.sigma), q)
minimum(d::MyDist) = -Inf
maximum(d::MyDist) = Inf
insupport(d::MyDist, x::Real) = insupport(Normal(d.mu, 2*d.sigma), x)
mean(d::MyDist) = mean(Normal(d.mu, 2*d.sigma))
var(d::MyDist) = var(Normal(d.mu, 2*d.sigma))
When I try plot(MyDist(0, 1))
, I get the following error: MethodError: no method matching start(::MyDist)
. If someone could help that would be awesome. Thanks a lot!