💾 Archived View for jaeyoung.se › posts › 2023-04-28_beta_distribution.gmi captured on 2023-05-24 at 17:51:06. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
date = 2023-04-28 tags = ["deno", "statistics"] title = "Beta distribution script"
The Beta distribution is the distribution of the underlying probability `p` given the result of a binomial trial, coin tosses for an example .
Using the Beta distribution, the posterior distribution of `p` given your prior belief and observations can be calculated with the following formula:
"Beta"(alpha_"posterior", beta_"posterior") = "Beta"(alpha_"likelihood" + alpha_"prior", beta_"likelihood" + beta_"prior")
I uploaded a Deno script that plots the posterior distribution of `p` on the terminal.
% deno run https://jaeyoung.se/toys/beta_dist.js Beta Distribution Visualizer Enter prior alpha and beta values. alpha = 1 and beta = 1 means an uninformed prior. alpha = 1 beta = 1 Prior probability distribution 1.00 ┼─────────────────────────────────────────────────────────────────────────────────────────────────── Observed alpha = 0, beta = 0 Enter observed (+/-) alpha and (+/-) beta values. alpha = 1 beta = 10 Posterior probability distribution 0.04 ┼ â•â”€â”€â”€â•® 0.03 ┤ â•â•¯ â•°â•® 0.03 ┤ â•â•¯ ╰─╮ 0.03 ┤ â•â•¯ â•°â•® 0.03 ┤ │ â•°â•® 0.03 ┤ â•â•¯ â•°â•® 0.02 ┤ │ â•°â•® 0.02 ┤ â•â•¯ â•°â•® 0.02 ┤ │ â•°â•® 0.02 ┤ │ â•°â•® 0.02 ┤ │ ╰─╮ 0.02 ┤ â•â•¯ â•°â•® 0.01 ┤ │ â•°â•® 0.01 ┤ │ ╰─╮ 0.01 ┤ │ â•°â•® 0.01 ┤â•â•¯ ╰─╮ 0.01 ┤│ ╰─╮ 0.01 ┤│ ╰──╮ 0.00 ┤│ ╰───╮ 0.00 ┤│ ╰──────╮ 0.00 ┼╯ ╰────────────────────────────────────────────────────
https://learning.oreilly.com/library/view/bayesian-statistics-the/9781098122492