|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.knowceans.sandbox.gauss.GmmGibbsSampler2
public class GmmGibbsSampler2
GmmGibbsSampler tests a simple Gibbs sampler that simulates the posterior of a Gaussian mixture model, i.e., the parameter distribution as a function of the evidence. Adapted from http://www.sph.umich.edu/csg/abecasis/class/815.23.pdf .
Sample each of the mixture parameters from conditional distribution: Dirichlet, Normal and Gamma distributions are typical.
Simple alternative is to sample the origin of each observation and assign observation to specific component (used here).
| Field Summary | |
|---|---|
private static int |
BURN_IN
burn-in period |
(package private) double[] |
data
|
private static int |
ITERATIONS
max iterations |
private static double |
MIN_GROUP
minimum members of a group |
private static int |
THIN_INTERVAL
sampling lag (?) |
| Constructor Summary | |
|---|---|
GmmGibbsSampler2(double[] data)
Initialise the Gibbs sampler with data. |
|
| Method Summary | |
|---|---|
(package private) void |
addObservation(double x,
int group,
double[] counts,
double[] sum,
double[] sumsq)
For updating mixture parameters |
void |
configure(int iterations,
int burnIn,
int minGroup,
int thinInterval)
|
private void |
gibbs(int k,
double[] probs,
double[] mean,
double[] sigma)
Main method: Select initial state ? |
(package private) void |
initialState(int k,
int[] group,
double[] counts,
double[] sum,
double[] sumsq)
Initialisation: Must start with an assignment of observations to groupings ? |
static void |
main(java.lang.String[] args)
Driver with example data. |
(package private) void |
removeObservation(double x,
int group,
double[] counts,
double[] sum,
double[] sumsq)
For updating mixture parameters |
(package private) int |
sampleGroup(double x,
int k,
double[] probs,
double[] mean,
double[] sigma)
Sampling a component, P(z_j=i | z_-j, x_j, theta) = pi_i * f(x_j | theta_j) / sum_m pi_m f(x_j | theta_m) Calculate the probability that the observation originated from each component. |
(package private) void |
updateEstimates(int k,
int n,
double[] prob,
double[] mean,
double[] sigma,
double[] counts,
double[] sum,
double[] sumsq)
Update the parameters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
double[] data
private static double MIN_GROUP
private static int THIN_INTERVAL
private static int BURN_IN
private static int ITERATIONS
| Constructor Detail |
|---|
public GmmGibbsSampler2(double[] data)
data - | Method Detail |
|---|
void updateEstimates(int k,
int n,
double[] prob,
double[] mean,
double[] sigma,
double[] counts,
double[] sum,
double[] sumsq)
k - n - prob - mean - sigma - counts - sum - sumsq -
int sampleGroup(double x,
int k,
double[] probs,
double[] mean,
double[] sigma)
Calculate the probability that the observation originated from each component. Use random number(s) to assign component membership.
x - k - probs - mean - sigma -
void removeObservation(double x,
int group,
double[] counts,
double[] sum,
double[] sumsq)
x - group - counts - sum - sumsq -
void addObservation(double x,
int group,
double[] counts,
double[] sum,
double[] sumsq)
x - group - counts - sum - sumsq -
void initialState(int k,
int[] group,
double[] counts,
double[] sum,
double[] sumsq)
k - group - counts - sum - sumsq -
private void gibbs(int k,
double[] probs,
double[] mean,
double[] sigma)
k - probs - mean - sigma -
public void configure(int iterations,
int burnIn,
int minGroup,
int thinInterval)
public static void main(java.lang.String[] args)
args -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||