Skip to content

Instantly share code, notes, and snippets.

@physicshinzui
Last active January 21, 2022 01:04
Show Gist options
  • Save physicshinzui/5ac202206f7029df8a928c2f6b7d9ab0 to your computer and use it in GitHub Desktop.
Save physicshinzui/5ac202206f7029df8a928c2f6b7d9ab0 to your computer and use it in GitHub Desktop.
Gamma distribution on Pluto.jl
### A Pluto.jl notebook ###
# v0.17.5
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
el
end
end
# ╔═╡ c31028b2-7a52-11ec-23c1-e1e0c2095220
begin
# using Pkg
# Pkg.activate()
using Distributions, PlutoUI, StatsPlots
end
# ╔═╡ d44a5670-0ec9-419f-96ad-3fc3418ac6f6
md"""
α: $(@bind α Slider(1:10))
θ: $(@bind θ Slider(1:10))
"""
# ╔═╡ f30ab07c-2922-4f1f-b36a-d913ab14a517
begin
d = Gamma(α, θ)
density(rand(d, 10^6), xlims=(0,50), ylims=(0,1),
label = "α=$(α), θ=$(θ)", lw = 3)
end
# ╔═╡ Cell order:
# ╠═c31028b2-7a52-11ec-23c1-e1e0c2095220
# ╠═d44a5670-0ec9-419f-96ad-3fc3418ac6f6
# ╠═f30ab07c-2922-4f1f-b36a-d913ab14a517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment