org.omegahat.Simulation.MCMC
Class CustomMetropolisHastingsSampler

java.lang.Object
  |
  +--org.omegahat.Simulation.MCMC.NotifyingMCMCObject
        |
        +--org.omegahat.Simulation.MCMC.BaseMarkovChain
              |
              +--org.omegahat.Simulation.MCMC.CustomMarkovChain
                    |
                    +--org.omegahat.Simulation.MCMC.CustomMetropolisHastingsSampler
All Implemented Interfaces:
MarkovChain, NotifyingObject, java.lang.Runnable
Direct Known Subclasses:
CustomMetropolisSampler

public class CustomMetropolisHastingsSampler
extends CustomMarkovChain

A Markov Sampler that uses an internal GenericProposal and UnnormalizedDensity to generate the next Markov state.


Inner classes inherited from class org.omegahat.Simulation.MCMC.CustomMarkovChain
CustomMarkovChain.listenerPrinter, CustomMarkovChain.NormalGenerator
 
Inner classes inherited from class org.omegahat.Simulation.MCMC.NotifyingMCMCObject
NotifyingMCMCObject.MyHandle
 
Field Summary
protected  boolean accepted
           
protected  java.lang.Object current
           
 boolean debug
           
protected  boolean detailed
           
protected  double log_p_X
           
protected  double log_p_Y
           
protected  double log_q_X_to_Y
           
protected  double log_q_Y_to_X
           
protected  double logAcceptProb
           
protected  int numAccepted
           
protected  int numProposed
           
protected  PRNG prng
           
protected  GeneralProposal proposal
           
protected  java.lang.Object proposed
           
protected  UnnormalizedDensity target
           
protected  double uniformRand
           
 
Fields inherited from class org.omegahat.Simulation.MCMC.CustomMarkovChain
generator
 
Fields inherited from class org.omegahat.Simulation.MCMC.BaseMarkovChain
state
 
Fields inherited from class org.omegahat.Simulation.MCMC.NotifyingMCMCObject
listeners
 
Constructor Summary
protected CustomMetropolisHastingsSampler()
           
  CustomMetropolisHastingsSampler(ContainerState state, UnnormalizedDensity target, GeneralProposal proposal, PRNG prng)
          Generate GenericChainStepEvents at each step
  CustomMetropolisHastingsSampler(ContainerState state, UnnormalizedDensity target, GeneralProposal proposal, PRNG prng, boolean detailed)
          Default constructor
  CustomMetropolisHastingsSampler(java.lang.Object state, UnnormalizedDensity target, GeneralProposal proposal, PRNG prng)
          Generate GenericChainStepEvents at each step
  CustomMetropolisHastingsSampler(java.lang.Object state, UnnormalizedDensity target, GeneralProposal proposal, PRNG prng, boolean detailed)
           
 
Method Summary
protected  double acceptanceProb(java.lang.Object current, java.lang.Object proposed)
           
 double acceptanceRatio()
           
 boolean accepted()
           
protected  java.lang.String arrayToString(java.lang.Object contents)
           
 java.lang.Object current()
           
 boolean detailed()
           
 boolean detailed(boolean flag)
           
 MCMCState generate(MCMCState state)
          Generate the next state from the current one.
 PRNG getPRNG()
           
 GeneralProposal getProposal()
           
 UnnormalizedDensity getTarget()
           
 double log_p_X()
           
 double log_p_Y()
           
 double log_q_X_to_Y()
           
 double log_q_Y_to_X()
           
protected  double logAcceptanceProb(java.lang.Object current, java.lang.Object proposed)
           
 double logAcceptProb()
           
static void main(java.lang.String[] argv)
           
 int numAccepted()
           
 int numProposed()
           
 java.lang.Object proposed()
           
 void resetCounters()
           
 void step()
          Generate the next state from the current state.
 double uniformRand()
           
 
Methods inherited from class org.omegahat.Simulation.MCMC.BaseMarkovChain
getState, iterate, run
 
Methods inherited from class org.omegahat.Simulation.MCMC.NotifyingMCMCObject
notifyAll, registerListener, unregisterListener
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

target

protected UnnormalizedDensity target

proposal

protected GeneralProposal proposal

prng

protected PRNG prng

debug

public boolean debug

current

protected java.lang.Object current

proposed

protected java.lang.Object proposed

logAcceptProb

protected double logAcceptProb

uniformRand

protected double uniformRand

accepted

protected boolean accepted

log_p_X

protected double log_p_X

log_q_X_to_Y

protected double log_q_X_to_Y

log_p_Y

protected double log_p_Y

log_q_Y_to_X

protected double log_q_Y_to_X

numProposed

protected int numProposed

numAccepted

protected int numAccepted

detailed

protected boolean detailed
Constructor Detail

CustomMetropolisHastingsSampler

protected CustomMetropolisHastingsSampler()

CustomMetropolisHastingsSampler

public CustomMetropolisHastingsSampler(ContainerState state,
                                       UnnormalizedDensity target,
                                       GeneralProposal proposal,
                                       PRNG prng,
                                       boolean detailed)
Default constructor

CustomMetropolisHastingsSampler

public CustomMetropolisHastingsSampler(java.lang.Object state,
                                       UnnormalizedDensity target,
                                       GeneralProposal proposal,
                                       PRNG prng,
                                       boolean detailed)

CustomMetropolisHastingsSampler

public CustomMetropolisHastingsSampler(ContainerState state,
                                       UnnormalizedDensity target,
                                       GeneralProposal proposal,
                                       PRNG prng)
Generate GenericChainStepEvents at each step

CustomMetropolisHastingsSampler

public CustomMetropolisHastingsSampler(java.lang.Object state,
                                       UnnormalizedDensity target,
                                       GeneralProposal proposal,
                                       PRNG prng)
Generate GenericChainStepEvents at each step
Method Detail

getProposal

public GeneralProposal getProposal()

getTarget

public UnnormalizedDensity getTarget()

getPRNG

public PRNG getPRNG()

current

public java.lang.Object current()

proposed

public java.lang.Object proposed()

logAcceptProb

public double logAcceptProb()

uniformRand

public double uniformRand()

accepted

public boolean accepted()

log_p_X

public double log_p_X()

log_q_X_to_Y

public double log_q_X_to_Y()

log_p_Y

public double log_p_Y()

log_q_Y_to_X

public double log_q_Y_to_X()

numProposed

public int numProposed()

numAccepted

public int numAccepted()

acceptanceRatio

public double acceptanceRatio()

resetCounters

public void resetCounters()

detailed

public boolean detailed()

detailed

public boolean detailed(boolean flag)

arrayToString

protected java.lang.String arrayToString(java.lang.Object contents)

generate

public MCMCState generate(MCMCState state)
Generate the next state from the current one. This method assumes that current is a ContainerState, and uses this to pass a "raw" object to the proposal and target.
Overrides:
generate in class CustomMarkovChain

acceptanceProb

protected double acceptanceProb(java.lang.Object current,
                                java.lang.Object proposed)

logAcceptanceProb

protected double logAcceptanceProb(java.lang.Object current,
                                   java.lang.Object proposed)

step

public void step()
Generate the next state from the current state.
Overrides:
step in class BaseMarkovChain

main

public static void main(java.lang.String[] argv)