JuliaStats / Distributions.jl

A Julia package for probability distributions and associated functions.
Other
1.11k stars 415 forks source link

Gamma distribution pdf has strange scale #788

Closed fpmenninger closed 6 years ago

fpmenninger commented 6 years ago

looking at :

using Gadfly, Distributions
g = Gamma(3,3)
x=range(0, stop=3, length=20)
plot(x=x, y=[pdf(g,i) for i in x])

results in a graph that instead of tapering to a thin tail at x=3, is just beginning to crest at x=3 (about where x=0.6 on the correct graph with the thin tail).

mschauer commented 6 years ago

All looks fine to me according to Wikipedia.

using Plots, Distributions
using SpecialFunctions
g = Gamma(3,3)
x=range(0, stop=3, length=50)
plot(x, [pdf(g,i) for i in x], lw=2)
f(x, k=3.0, θ = 3.0) = 1/gamma(k)*θ^-k * x^(k-1) * exp(-x/θ)
plot!(x, [f(i) for i in x], linestyle=:dash, lw=2)

Do you have a different parametrization in mind (the second parameter in Julia is scale).

help?> Gamma

  Gamma(α,θ)

  The Gamma distribution with shape parameter α and scale θ has probability
  density function
fpmenninger commented 6 years ago

Got it. Using theta (scale) and wanting beta (rate). Thanks.