BAYES_WEIGHT is a FORTRAN90 program which demonstrates Bayesian analysis.
The program estimates the weights used in a mixture probability density function (PDF). In the case examined here, the parameters of the PDF's are known, but the mixing weights are not. It is the task of the program to observe the system and estimate these weights.
Each event will be a roll of a die. We have two dice to choose from, each with a different characteristic probability density function. For each event, the probability we will choose die #1 or die #2 are the unknowns W1 and W2. We start with a guess for these values, but after each roll, we adjust our guesses based on the product of the likelihoods of observing this result given that density, and our previously estimated likelihood of that density.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
BAYES_WEIGHT is available in a FORTRAN90 version.
BAYES_BETA, a FORTRAN90 program which uses Bayesian analysis to estimate the parameters in a beta distribution based on a series of sample data.
BAYES_DICE, a FORTRAN90 program which uses Bayesian analysis to estimate the probabilities of a weighted die.
DCDFLIB, a FORTRAN90 library which evaluates and inverts a number of statistical distributions.
GSL, a C++ library which includes many routines for evaluating probability distributions.
NORMAL, a FORTRAN90 library which samples the normal distribution.
PROB, a FORTRAN90 library which evaluates the PDF, CDF, mean and variance for a number of probability density functions.
UNIFORM, a FORTRAN90 library which samples the uniform distribution.
You can go up one level to the FORTRAN90 source codes.