Class MetropolisHastingsMV

    • Field Detail

      • myCurrentX

        protected double[] myCurrentX
      • myProposedY

        protected double[] myProposedY
      • myPrevX

        protected double[] myPrevX
      • myLastAcceptanceProbability

        protected double myLastAcceptanceProbability
      • myFofProposedY

        protected double myFofProposedY
      • myFofCurrentX

        protected double myFofCurrentX
      • myInitialX

        protected double[] myInitialX
      • myAcceptanceStat

        protected final Statistic myAcceptanceStat
      • myObservedStatList

        protected final java.util.List<Statistic> myObservedStatList
      • myInitializedFlag

        protected boolean myInitializedFlag
      • myBurnInFlag

        protected boolean myBurnInFlag
      • myStream

        protected RNStreamIfc myStream
        myRNStream provides a reference to the underlying stream of random numbers
    • Constructor Detail

      • MetropolisHastingsMV

        public MetropolisHastingsMV​(double[] initialX,
                                    FunctionMVIfc targetFun,
                                    ProposalFunctionMVIfc proposalFun)
        Parameters:
        initialX - the initial value to start generation process
        targetFun - the target function
        proposalFun - the proposal function
    • Method Detail

      • create

        public static MetropolisHastingsMV create​(double[] initialX,
                                                  int burnInAmount,
                                                  FunctionMVIfc targetFun,
                                                  ProposalFunctionMVIfc proposalFun)
        Parameters:
        initialX - the initial value to start the burn in period
        burnInAmount - the number of samples in the burn in period
        targetFun - the target function
        proposalFun - the proposal function
      • runBurnInPeriod

        public void runBurnInPeriod​(int burnInAmount)
        Runs a burn in period and assigns the initial value of the process to the last value from the burn in process.
        Parameters:
        burnInAmount - the amount to burn in
      • initialize

        public void initialize()
        Resets statistics and sets the initial state the the initial value or to the value found via the burn in period (if the burn in period was run).
      • resetStatistics

        public void resetStatistics()
        Resets the automatically collected statistics
      • isInitialized

        public final boolean isInitialized()
        Returns:
        true if the process has been initialized
      • isWarmedUp

        public final boolean isWarmedUp()
        Returns:
        true if the process has been warmed up
      • runAll

        public final double[] runAll​(int n)
        Parameters:
        n - runs the process for n steps
        Returns:
        the value of the process after n steps
      • getCurrentX

        public final double[] getCurrentX()
        Returns:
        the current state (x) of the process
      • getProposedY

        public final double[] getProposedY()
        Returns:
        the last proposed state (y)
      • getPrevX

        public final double[] getPrevX()
        Returns:
        the previous state (x) of the process
      • getLastAcceptanceProbability

        public final double getLastAcceptanceProbability()
        Returns:
        the last value of the computed probability of acceptance
      • getFofProposedY

        public final double getFofProposedY()
        Returns:
        the last value of the target function evaluated at the proposed state (y)
      • getFofCurrentX

        public final double getFofCurrentX()
        Returns:
        the last value of the target function evaluated at the current state (x)
      • getAcceptanceStat

        public Statistic getAcceptanceStat()
        Returns:
        statistics for the proportion of the proposed state (y) that are accepted
      • getObservedStat

        public java.util.List<Statistic> getObservedStat()
        Returns:
        statistics on the observed (generated) values of the process
      • next

        public double[] next()
        Moves the process one step
        Returns:
        the next value of the process after proposing the next state (y)
      • acceptanceFunction

        protected double acceptanceFunction​(double[] currentX,
                                            double[] proposedY)
        Computes the acceptance function for each step
        Parameters:
        currentX - the current state
        proposedY - the proposed state
        Returns:
        the evaluated acceptance function
      • getFunctionRatio

        protected double getFunctionRatio​(double[] currentX,
                                          double[] proposedY)
        Parameters:
        currentX - the current state
        proposedY - the proposed state
        Returns:
        the ratio of f(y)/f(x) for the generation step
      • getInitialX

        public final double[] getInitialX()
        Returns:
        the specified initial state or the state after the burn in period (if run)
      • setInitialX

        public final void setInitialX​(double[] initialX)
        Parameters:
        initialX - the value to use for the initial state
      • resetStartStream

        public void resetStartStream()
        Description copied from interface: RNStreamControlIfc
        The resetStartStream method will position the RNG at the beginning of its stream. This is the same location in the stream as assigned when the RNG was created and initialized.
        Specified by:
        resetStartStream in interface RNStreamControlIfc
      • setAntitheticOption

        public void setAntitheticOption​(boolean flag)
        Description copied from interface: RNStreamControlIfc
        Tells the stream to start producing antithetic variates
        Specified by:
        setAntitheticOption in interface RNStreamControlIfc
        Parameters:
        flag - true means that it produces antithetic variates.
      • addObserver

        public void addObserver​(ObserverIfc observer)
        Description copied from interface: ObservableIfc
        Allows the adding (attaching) of an observer to the observable
        Specified by:
        addObserver in interface ObservableIfc
        Parameters:
        observer - the observer to attach
      • deleteObserver

        public void deleteObserver​(ObserverIfc observer)
        Description copied from interface: ObservableIfc
        Allows the deletion (removing) of an observer from the observable
        Specified by:
        deleteObserver in interface ObservableIfc
        Parameters:
        observer - the observer to delete
      • contains

        public boolean contains​(ObserverIfc observer)
        Description copied from interface: ObservableIfc
        Returns true if the observer is already attached
        Specified by:
        contains in interface ObservableIfc
        Parameters:
        observer - the observer to check
        Returns:
        true if attached
      • countObservers

        public int countObservers()
        Description copied from interface: ObservableIfc
        Returns how many observers are currently observing the observable
        Specified by:
        countObservers in interface ObservableIfc
        Returns:
        number of observers
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • asString

        public java.lang.String asString()